Closed (fixed)
Project:
Flag
Version:
6.x-2.0-beta3
Component:
Flag core
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Nov 2010 at 02:08 UTC
Updated:
3 Jan 2014 at 02:41 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
mgriego commentedJust realized I flubbed part of the patch. There's actually no real reason to delete the flag from the database before re-saving it, and doing so is actually problematic. Reworking the patch and testing it now.
Comment #2
mgriego commentedOK, here's the revised patch. Obviously, I was a bit tired when I rolled the original patch last night. After reviewing and testing, it's now much simpler and works better.
Comment #3
mgriego commentedReporting back that we've been using this patch on a production site since the last comment (Nov 11), and it's been working great. We've been able to revert features without the loss of Flag data.
Comment #4
mooffie commentedWe have a duplicate issue: #969372: flag_features_revert doesn't really do what I'd except it to do
(I had the impression it was you who started it, perhaps because it was reported almost on the same day, so I didn't bother to notify "you" earlier.)
(I like that other issue's patch better because it doesn't have a loop.)
Comment #5
hefox commentedBah, how did I miss this issue? Here's the patch from that issue (marking that one as duplicate)
Comment #6
mooffie commentedHere's hefox's patch with minor changes:
- Removed "&& $this->name".
- Changed drupal_clone() to clone() to be compatible with D7. Flag 2.x is php5 only. I don't think clone is needed but it's logical.
- Reset flag_get_flags()'s cache.
- Documentation.
One potential problem:
We're doing "flag_get_default_flags(TRUE)" to load disabled flags as well. But then we have the problem described here, of writing to database a structure of an older API we aren't compatible with.
Perhaps we should define an is_compatible() method that tells us if the flag is compatible with the current Flag version, and save() and export it only if it is.
Comment #7
mgriego commentedOy. Looking back, I'm not sure why I did that loop over all the flags. *sigh* Oh well. Looks pretty much the same except for that loop.
With a potential is_compatible() method, what would happen if someone had a Flag that was overridden, and the in-code version was from an older API version, but the database version was current?
Comment #8
mooffie commented($flag->is_compatible() was committed.)
Here's an updated patch.
See tha patch: The revert operation won't proceed and the user will see an error message explaining this to him.
(BTW, the "database version" is always current: it was created when your Flag module was old, and, as with all the other database flags, the "upgrade paths" in the .install file keep it up-to-date.)
Comment #9
mooffie commentedCommitted.
http://drupal.org/cvs?commit=470124
http://drupal.org/cvs?commit=470126
Let me know if you see any problem with this.
(And if you see any, make sure you didn't fall victim to #875276: Cannot export disabled flags to features)
Comment #10
quicksketchThanks mooffie. :)