Closed (won't fix)
Project:
Flag
Version:
6.x-2.x-dev
Component:
Flag core
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
18 Jun 2009 at 15:43 UTC
Updated:
7 Oct 2010 at 19:11 UTC
Jump to comment: Most recent file
Comments
Comment #1
sirkitree commentedboy, wish we had a better way to flag this issue ;) +1
Here's a re-roll against dev and from within the flag module's directory.
Comment #2
quicksketchI'm not sure why this code is part of this patch:
In any case, it would be
drupal_alter('flag_default_flags', $default_flags);, otherwise the hook would be called hook_default_flags_alter_alter(), when we want it to be hook_flag_default_flags_alter(). This change should be broken out into a separate patch either way, not bundled in this one.Comment #3
jmiccolis commented@quicksketch, I left the drupal_alter in this patch because it's immediately needed once we start including default flags. ...as people with complex sites will need a way to disable the single default now in the module.
I can certainly split if off into another patch if you really need it to be, but to me it would essentially be a bug fix patch, which is why I left it in place.
Comment #4
jmiccolis commentedHere is the dev patch with the hook renamed.
Comment #5
quicksketchWouldn't the need for the hook be fixed by #435822: Implement hook_flag_alter? I think that it affects default flags as well as database driven ones (not positive, it's been a while since I reviewed it).
The hook is still named incorrect in #4. It should be
drupal_alter('flag_default_flags', $default_flags);(leave off the trailing '_alter', Drupal adds that for you ).Comment #6
jmiccolis commentedAttached is a patch that addresses the extra '_alter' and provides a default that functions (I'd omitted the content_type element initially).
Regarding the hook_flag_default_flags_alter() vs hook_flag_alter(), yea these two would be in competition. Personally I agree with moofie's idea that the "more powerful approach is to let programmers alter the handlers' definitions" , which is what views does (with hook_views_data_alter()). Regardless of the diversion into the discussion of delegators, I think believe this is the stronger approach and is a familiar concept from views.
Comment #7
manuel garcia commentedI'm a bit confused by this, according to this documentation page, there's already a hook_flag_default_flags ? or is that doc page wrong there?
Comment #8
quicksketchThere is a hook_flag_default_flags(), which allows the creation of new flags. This issue is sort of a muddle between actually making flag.module implement it's own hook and also adding hook_flag_default_flags_alter(). The _alter() part should probably be dropped since you will be able to accomplish that with #435822: Implement hook_flag_alter. I'd prefer not to add two hooks when one will do just fine.
Comment #9
manuel garcia commentedow right ok, i see... I'm very glad that #435822: Implement hook_flag_alter is geting worked on, I was last night hammering my head against the wall trying to store some other configuration options for the flag in a module... can't wait for that to happen- flag ftw!
ps. thanks for the explanation =)
Comment #10
jmiccolis commented@quicksketch regarding the two alter hooks proposed here and on #435822 I'd like to explain my position a bit better. The appeal of a default only alter is that it gives a developer access to make existing flags compatible or to disable them. It is a simple and targeted hook. I think that being able to target default flag definitions is a critical part of offering these defaults. As such, I haven't removed it from the patch above.
My issue with the general alter flag (as I understand it) is that it:
Comment #11
quicksketchFlag works a bit differently in that the distinguishment between "default" and "database" is very blurry. Unlike Views that clearly has code-based views and database-based views, even "default" flags are loaded into the database to give them a FID. So a code-based Flag really is nothing but a database flag with a few items that have been "locked" by code. So therefor, the ability to distinguish whether flag is a "default" is not actually that important, but you can easily tell which flags have locked properties by checking !empty($flag->locked). However if we want to make code-based flags easy to identify, it'd be pretty easy to make $flag->default = TRUE.
I expect that any altering that is done would probably want to set $flag->locked['property_name'] so that it would become locked in the UI. This can affect database and code-based flags equally.
If 2 hooks were added (both default and normal flag altering), the general flag_alter would be run second anyway, so providing a default_flag_alter() doesn't guarantee anything would not be overridden by the second hook.
So I'm still largely opposed to making 2 hooks when one will do. While Flag uses Views as a model for a lot of things, our implementation of "default" flags is not one that's entirely similar. Though I could be entirely wrong, I can't see a reason why it's needed.
Comment #12
quicksketchIt would be handy to be able to "disable" a flag entirely if needed, but because flags are loaded into the database, removing a flag through hook_default_flags_alter() would not actually disable it in any way, since it will also be in the database (though it would "unlock" all it's properties and the user could delete it if desired).
Comment #13
jmiccolis commentedI understand you points here, and what I'd trying to push for is to make the line between database and default flags less blurry. Getting that distinction more defined allows for flags to be tied to other exported definitions. My interest there is that flags can become parts of larger sets of exported elements and managed across sites & deployments.
Comment #14
quicksketchI realized that we already have a $flag->default property: You can just check $flag->module, if it's set then the flag is being provided by that module.
I've stated above several reasons why we don't need another hook. Unless a situation can be raised (and a practical usage) for something that cannot be done with the current hooks then another hook will not be created.
Comment #15
tim.plunkettMy understanding is that this issue was "won't fix"-ed because there is no need for an extra _alter hook. However, the title and the OP are still valid concerns.
I came across this issue while trying to understand why
flag_get_default_flags()wasn't returning 'bookmarks'. I considered opening a separate issue, but I didn't want to have two issues with identical titles.The attached patch is similar to the others, but has been updated to 6.x-2.x-dev. The only real changes were removing the now unnecessary
flag_enable(), and adding'api_version' => 2,to preventflag_update_page()from being called.The unrelated _alter hook has been removed.
Comment #16
quicksketchThe "bookmarks" flag is intended to be a temporary flag, not a permanent one. I think it would be common that a user would want to export the bookmarks flag (after modification) into their own module or feature. If Flag is already providing the bookmarks flag, then you'd have 2 modules competing for the same namespace. Flag intentionally provides this a "starter" flag that you can easily delete or modify in any way you want. It's intended to be an example, rather than an integral part of the module or something you can count on being there.
Comment #17
tim.plunkettWell, that makes sense.