Closed (fixed)
Project:
Menu Token
Version:
7.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Nov 2016 at 21:10 UTC
Updated:
6 Dec 2016 at 17:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
polHi,
Here's the patch for this issue.
Comment #3
polComment #4
miroslavbanov commentedSuch a code as in #2 existed and was changed in #1895628: Entity type does not necessarily match token type.
Commit http://cgit.drupalcode.org/menu_token/commit/?h=7.x-1.x&id=98aaab16be810...
By adding it back, are we introducing a regression?
Comment #5
alexverb commentedWhat if we were just to replace all this entity_info stuff with menu_get_item? I'm sure it can even be more simplified than this, as it allready holds the entity. I'm not sure about the entity type checking though:
Just a thought.
Comment #6
alexverb commentedHere is a better version:
The entity type check is probably not needed.
What do you think?
Comment #7
alexverb commentedLooks like menu_get_item() resulted in an infinite loop on the menu link edit pages.
Here's a patch that just get's the router item and loads the entity.
There's still a problem with validation of menu link edit pages.
But I think that's best handled in a seperate ticket which is here #2768767: Menu link validation fails
Comment #8
alexverb commentedIncreasing priority because current beta7 is broken. We need a solution for this as fast as possible.
Comment #9
miroslavbanov commentedI like the approach in #7. I think some unnecessary things can be removed from the code still. Attaching patch.
Comment #10
alexverb commentedThanks @MiroslavBanov, indeed simplified like that. Just a few more questions I want to have answered:
We can go ahead with the patch without knowing the answer to the ajax question. The approach of the patch is an actual extension and improval of previous functionality. People will eventually stumble upon the arg() bug if there is one...
The entity access question we should answer. I can see use cases where we would always want the entity returned and I can see use cases where we would want to have an access check. To me this looks like a hard problem to solve. Maybe we should open a feature request for this as an extension to the menu link edit form where you can set an extra parameter for the plugin class. Such a thing does feel like we are making it complicated for some users. A good solution would be to provide an extra module setting to enable such functionality.
I will try to do some testing today on your patch @MiroslavBanov
Comment #11
miroslavbanov commentedComment #12
polI also agree with you @MiroslavBanov.
Comment #13
alexverb commentedAllright, I've tested this on regular paths for node, user and taxonomy.
These work as expected. Setting to RTBC. Doesn't mean you shouldn't test :)
We should be expanding the menu_token.test though.
But this is not really useful as long as test are not enabled on this repository...
Comment #14
alexverb commentedDoesn't work on views. I'm working on a new patch.
Comment #15
alexverb commentedHi all, so this patch also allows for views arguments to be loaded.
I can't seem to think of any other implementations for the contextual entity loading plugin.
Before we go back to RTBC we need to decide if we want to inform the user about the change in functionality. This because until beta7 the argument position was fixed, and has now become dynamic. A possible side effect of this change could be that menu links will appear where the site builder didn't expect them. It's easily solvable by them by setting the display of the menu only at the desired paths.
A suggestion I have for this is to:
I know this will result in cruft code, but I think it's worth it.
Whether or not we decide to do this, for sure this has to be entered into a README.txt (which we surprisingly do not yet have)
Comment #16
miroslavbanov commentedViews argument looks OK to me. I was a bit concerned that entity type is not sufficiently verified for it, but I guess this part should be enough:
array_key_exists($entity_key, $view->argument)Personally, I wouldn't bother with warning the user. The plugin is pretty much broken without this patch.
Comment #17
miroslavbanov commentedI say this is RTBC.
If you want to add docs or tests or user warnings, go right ahead. I wouldn't bother for a module where tests are not even enabled.
Comment #18
alexverb commentedYeah, it is probably professional deformation as I'm in the quality assurance business. But if there were tests for entity tokens in this module we would have never hit this point. I'm surprised there aren't more complaints looking at the popularity of this module.
I'll make a separate issue for tests and documentation. So we can proceed with getting this bug fixed as a priority.
Comment #19
polVery good initiative guys.
Comment #21
develcuy commentedThanks alexverb and MiroslavBanov!