Closed (fixed)
Project:
Features Extra
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Sep 2011 at 04:23 UTC
Updated:
16 Sep 2017 at 09:11 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
perarnet commentedI tried your patch from http://drupal.org/node/1083394#comment-4857390, but can't see date_formats showing up.
Comment #2
derhasi commentedThere is a reworked patch for this issue. (Forgot to include the system module)
Comment #3
derhasi commentedAnd there it is with support for date format types.
Comment #4
mrfelton commentedThis causes a fatal error if you dont have the locale module enabled.:
Comment #5
derhasi commentedOh, sure fixed that.
Comment #6
mrfelton commentedThats better, although it doesn't apply cleanly, so can't use it with Drush make. Here is one that does.
Comment #7
mrfelton commentedConfirm that the patch worked. When you have strongarm enabled, you also get the option to export a variable fo r each date format. Are these still needed with using the above? Do you know how the system variables relate to the other database settings that are being managed by this patch?
Comment #8
derhasi commentedThe variables are for the default format of the exported date format type (see hook_date_format_types). In the current patch they are set in
date_formats_features_rebuild(), as this is an obligatory step for enabling/setting the date format correctly.So dependency on strongarm was not good. But we could add the variables to the pipe, so they get exported automatically (in most cases) to the relevant feature.
edit: mrfelton, please look for the patch naming convention... so a patch can be easily related to the issue number ;)
Comment #9
mpotter commentedI'd like to see a bit more work before committing this to deal with the variables issue. I've got sites exporting custom date types via strongarm which works fine. What am I gaining by having this in Features instead of just using Strongarm? What happens on my sites that already export the variables...will I need to rebuild those features?
Comment #10
derhasi commentedAttached is a new patch with the pipe-part for strongarm applied to the current dev.
mpotter, to your annotations: using features for date_formats covers also locale date formats. If you haven't strongarm enabled, you still could export the date formats.
If it's ok to have a dependency for that core component, I'd propose to rename the "Date formats" component to "Locale date formats" and only deal with locale date formats for that component.
How about additional pipes?
* locale date formats => language
* date format type => strongarm:date_format
Comment #11
derhasi commentedmpotter, do u have any opinion on the road to go?
Comment #12
mpotter commentedsorry, been busy at DrupalCon. I'll try to evaluate this next week. I'd like to feature-freeze features 1.x so we can get 1.0 released soon, but if this works with no negative impact on existing sites then I will see about getting it in.
Getting some other people to help review this also would be a big help.
Comment #13
hefox commentedWhy the separate variables instead of $pipe['date_format_types'] .. ? Looks a bit unnecessaryly messy.
Adding information for another module (strongarm) feels a bit weird to me.
Filter_default_formats?
This whole variable_set vs strongarm thing is weird. Really not comfortable for it.
Don't see any reason for this; just don't implement the hook. rebuild is optional. Can people override default date formats? If so, do need a _revert but not a rebuild.
Not checking if that actually returns anything than running unserialize? ow ow.
New line
I sorta think this should go into something that depends on strongarm, though not sure what that'd be (a sub module of features? a submodule of strongarm? a separate project?)
Comment #14
derhasi commentedOk, I will rework that soon to the " locale date formats" approach. So we have no fuzzy dependencies.
Comment #15
derhasi commentedAnd finally there's the reworked patch for that issue.
* date format types are implemented via core hook.
* Strongarm is "piped" for default formats of a type.
* locale date formats are exportable via component: pipes its date format type.
@hefox, noticed your comments and put it into code.
IMHO using the weak dependency on strongarm is the best way, as strongarm is a common contrib.
Comment #16
mrfelton commentedNice. Works well. Although applying the patch gives a whitespace warning:
Comment #17
alex.skrypnykTried patch in #15 against 7.x-1.0-rc2 - new date types and format does not appear.
Workflow:
1. Patched Features module and copied to Site1 and Site2
2. Created new date type
3. Created new date format
4. Assigned date format to date type
5. Created Feature, containing only date type on Site1 and copied it to Site2
6. Enabled feature on Site2
7. Cleared all cache
8. Neither date type nor date format appeared under admin/config/regional/date-time.
Feature code below:
@derhasi
Are there any actions to be done to make it work?
Comment #18
mrfelton commented@alex.designworks Are you sure you included the date type component in your feature? Doing so should result in an implementation of hook_date_format_types() in your feature.
Comment #19
alex.skrypnykI'm not sure what "date type component" is, but in Features UI there is a dropdown 'Edit components' where I selected 'Date' as dependency. Even tried to select 'Date API' as dependency.
Using Strongarm I selected variable 'date_format_short_string' (my format name).
Still no luck - no implementation of hook_date_format_types().
Could you please describe the process of how this kind of feature would be created since, apparently, auto-discover does not pick up required components?
Thanks
Comment #20
thedavidmeister commentedFor instructions on how to export date formats and date format types while this is getting fleshed out, check this duplicate thread #911940: Integration with Date (has a link pointing back here).
Comment #21
dalinThe patch in #15 worked for me. I included both the date format types and the strongarm variables date_format_[format] in my feature and I successfully reverted the feature on the destination site and everything is functional. The only issue being that the formats don't appear at /admin/config/regional/date-time/formats because nothing exists in {date_formats} because nothing is added to the feature. This is probably not within the sphere of Features module since {date_formats} has numeric IDs.
Comment #22
rballou commentedI think it would be great for features to add support for date formats and date format types. I do think it would be ideal if the integration could get around the numeric ID issue in some way but I'm not sure the best approach there. Are there any strategies we could take to get this functionality added? I can certainly help review or add code as needed. Thanks!
Comment #23
derhasi commented@alex.designworks, there should be a "Date format types" component.
@dalin, rballou,I unfortunately don't get the numeri id problem :/
Comment #24
dalinNumeric IDs is the reason that Features module does not manage blocks, menus or taxonomy either (@see Features Extra module). The reason being that if for example you enable a feature on your site and the ID for the item (block/menu/term/whatever) already exists, there's no way to know if this matches the item in your feature (and thus it should be updated), or if this is another item that was created on that site (and thus a new item should be created).
Comment #25
thedavidmeister commentedExample:
You have site A and site B.
You create three taxonomy terms (or anything else with a numerical ID) in A with ID's 1, 2 and 3.
You create a representation of the term with ID 2 in code (Features) that you want to push to site B.
Site B could have no terms, or 50 terms or anything else.
When you push the term to site B is it supposed to update (override) the term in the database that already has an ID of 2 or is it supposed to create a new term with those attributes with id 50?
In the case where ID's are created sequentially in the system, there's no "intention" of the developer/site admin we can infer and in the case where ID's can be freely edited by site admins/content managers (like term names) developers don't want to accidentally override something they aren't supposed to be touching while deploying new functionality.
Not an issue when you're creating a new site from scratch because everything is new, is an issue in the general case where you're using Features to deploy things in an ongoing fashion to existing sites that are already full of content.
It's possible to give *everything* a universally unique id (called a UUID) and reference that so you "create it if it doesn't exist, update the thing we exported and don't touch anything we don't know about" but it turns out to "guarantee" that a unique ID is really unique we end up with very long hashes and pulling results out of a database by referencing big, random numbers/strings is much slower than sorting/finding something indexed with a sequential ID. I think we can all agree that the last thing Drupal needs is *another* fundamental part of its "best practice" framework substantially slowing down page load times.
Things that have an unchangeable "machine id" that is set by a human's conscious decision when the thing is created are also easy to export because it is always "update if it exists, create it if it doesn't" which is "revert" in Features-speak. This is the current "best" approach to export things.
The Features-way of doing things is in core in Drupal 8 so the problem of deploying *functionality* (not content, yet, that's happening here - http://drupal.org/project/deploy) should dissipate completely over the next few years but at the moment it's not always obvious how to upgrade everything to the new paradigm without data loss for existing sites.
There's also no "one size fits all" solution that can be posted in a wiki where maintainers can reference it because every module is doing things in its own way to some extent - the double edged sword of open source innovation is that some innovations progress the quality and state of the platform and some end up being counter-productive.
This is the Numeric ID problem.
Comment #26
mpotter commentedBecause of the issues in #17 this needs more work. Also I am unsure about marking this as the implementation of the "system" module. There are a lot of other things controlled by "system" that this does not export. So it's a bit different than other core Features like "fields".
My feeling is that this really needs to go into a contrib module like Features Extra did and isn't going to be an easy addition to core Features.
Comment #27
kclarkson commentedAre custom date formats going to be implemented in the 7.x-2.x version ?
Comment #28
nevergoneAnd now?
Comment #29
discipolo commentedas mentioned this patch exports date types correctly. if i understand correctly the ability to add date formats is out of this modules scope and should maybe be investigated in the features_extra issue queue
edit: i just realized that it is possible to export date formats once the locale module is enabled. so maybe the numbered id issue doesnt apply after all (though the formats still dont import, not even with locale). i was just about to try out http://drupal.org/sandbox/rballou/1699026 ...
Comment #30
rballou commentedThat sandbox module you point to will get both, but it's "ignoring" the numeric ID issue. It's intention was to work in a case where we can assume the feature was enabled when first installing the site. It's not necessarily robust for full usage. My understanding is too many other things point to format ID numbers...
Comment #31
user654 commented.
Comment #32
thedavidmeister commented#31 - http://thedavidmeister.info/post/exporting-and-maintaining-custom-date-f...
Comment #33
tobiasbWhat is the decision? Include it in features, features extra or a own project?
I build a own module for that with the components date types, localized format and custom formats (without ID ;-)).
I created a gist for you to take a look at the code ;-).
https://gist.github.com/tobiasbaehr/7292175
Comment #34
ladybug_3777 commentedI'm also curious what the decision is for this. It hasn't been updated in 6 months, is this closed and won't be fixed/addressed?
Comment #35
discipolo commentedthat gist looks like it could be turned into a patch for features_extra easily ... does that code work without the most recent patch from this queue?
Comment #36
tobiasbYes it works without the patch from here, because I used some code fragments from the patch.
Comment #37
joris_lucius@tobiasb Thanks a lot, #33 worked.
Comment #38
yingtho commentedI moved the issue to Features Extra and include a patch as well that is inspired from #33 but aligned with the naming convention of feature extra.
Comment #41
samhassell commentedPatch applies fine, date strings and formats seem to export fine, but when reimported they are stuck in the overridden state.
Comment #49
rosk0Fixed issue with reverting date types plus small code style fixes.
Comment #50
lklimek commentedI've installed patch from #49 and it seems to work.
Comment #51
aitala commentedI've installed patch #49 and fe date does not appear in the module list. Tried clearing cache, registry rebuild, cron, etc..
Eric
Comment #52
JvE commented@aitala: The patch has to be applied to the features_extra directory (in sites/all/modules/).
I suspect you applied the patch to the drupal root which placed the 2 files there. If so, then simply move the 2 files (fe_date.info and fe_date.module) to the features_extra directory.
Comment #53
aitala commented@JvE : Actually, the files were in the features_extra directory... just did not work.
I ended up just not using the module as a whole...
Eric
Comment #54
drupov commentedPatch from #49 applies perfectly and works great. Thanks!
Comment #55
markus_petrux commentedDitto. Thanks!
Comment #56
stefan.r commentedTested this and this still works like a charm!
Comment #58
pfrenssenGreat stuff! Fixed some nitpicks and committed to 7.x-1.x. Thanks a lot everybody!
No need for parentheses here.
These parentheses are also not needed, the comparison operator has a higher precedence than the ternary operator.
Comment #59
pfrenssenComment #61
honza pobořil commentedBtw, it will be good to mention this feature on the project page.
Comment #62
ciss commentedIn our case clearing the cache was required for a custom type to show up, even after a forced revert. Just mentioning it in case someone else runs into this problem.