Closed (fixed)
Project:
XML sitemap
Version:
7.x-2.x-dev
Component:
xmlsitemap_menu.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
23 Mar 2014 at 08:10 UTC
Updated:
26 Sep 2014 at 15:41 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
honza pobořil commentedSo what solution do you recommend?
Comment #2
joachim commentedEither use hook_entity_info() instead of hook_entity_info_alter(), or provide the token type.
Comment #3
damienmckennaAs XMLSitemap does not depend upon the Token module, I don't think it's strictly a bug in XMLSitemap.
Comment #4
joachim commentedIf you used hook_entity_info() instead of hook_entity_info_alter() then Token module would be able to act and provide the token type for you.
Comment #5
pafla commentedHow and where to edit this?
Comment #6
dandaman commentedWould it also fix it if we changed xml sitemap to run the alter before token then?
Comment #7
shawn dearmond commented@dandaman's solution worked for me. I changed the module weight to -1, and it passed all tests.
Attached is a patch that implements it.
PLEASE REVIEW because there might be other consequences of changing module weight.
Comment #8
daveferrara1 commentedHaving the errors too. Mainly triggering this error:
Notice: Undefined index: token type in flag_token_info() (line 88 of /srv/bindings/9fe9a2846c534faab85e3b36c93bb52c/code/sites/all/modules/flag/flag.tokens.inc).Comment #9
daveferrara1 commentedPatch in #7 worked for me.
Comment #10
grimreaperHello,
I attach a patch that add a 'token type' key in the hook_entity_info_alter.
I don't test if it is the proper solution but it solved the warning.
I don't think the patch in #7 is a good solution because it only hides the problem. And the hook_update_N in this patch is for a D6, no ?
Thanks for the review.
Comment #11
joachim commentedThing is, this is going to happen with any entity info property that another contrib module wants to add to all entities and then rely on.
The real problem is that the hook is being misused: alter hooks should not add a whole new item to an info array.
Comment #12
dave reidThe problem is that we're registering an entity type for a table provided by core. What happens when another contrib module wants to declare menu links as entities and does the same thing? *boom* This is why the alter hook is used currently because this is not a theoretical problem at this exact moment.
Comment #13
joachim commentedYeah... contrib projects need to agree amongst themselves who gets to entitize a particular core table. Or declare on their project pages that they're mutually incompatible.
Comment #14
justanothermark commentedI agree this is a wider problem & not sure of the fix but if the workaround in #10 is to be used then it should use the key 'token type' (as mentioned in the comment) and not 'token info' (as used in the patch).
Comment #15
grimreaperHello,
Thanks for the review, you're right justanothermark, it's 'token type'. I tested at work, and I rewrote a patch at home and I didn't realize I wrote a wrong key.
In the token module in the hook_entity_info_alter :
So the value should be 'menu_link'.
Here is a patch with the right key and value.
Comment #16
thedavidmeister commentedApplying the patch in #15 to the latest dev has caused the notices to cease for me.
Comment #17
kerrycurtain commentedConfirming the patch in #15 worked for me, Thank you.
Comment #18
rooby commentedEntitizing (funny word :)) a core table should not be done by some random module that needs to use that data as an entity, because if you try to do it that way then you are relying on some other unrelated module that a user may not want to use.
Ideally it should be in a module that specifically does just the entitizing and then is required by other modules that need it.
So in this case some sort of menu_item_entity module would handle just this entity definition and any other modules that need it require it.
This seems to be kind of what entity_menu_links does although it also has some things that a straight entitizing module doesn't really need, like the UUID/services stuff so it isn't really a candidate for a dependency of xmlsitemap.
Comment #19
joachim commented> So in this case some sort of menu_item_entity module would handle just this entity definition and any other modules that need it require it.
Exactly. Same way that a slim File Entity module was refactored out of Media module: https://www.drupal.org/project/file_entity
Comment #20
mamanerd commentedThe patch in #15 worked for me as well.
Comment #21
agileware commentedPatch #15 works for me.
Comment #23
dave reidCommitted #15 to 7.x-2.x. Thanks everyone.