Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Power menu allows menu links to be fieldable by creating entities for them. The problem is entities can not be safely stored in $_SESSION. It will cause a nasty "Call to undefined function entity_get_info()" on every page. See http://drupal.stackexchange.com/questions/69824/session-breaks-entity-api .
I dunno if this is something to commit but I'll post a patch for anybody who needs to use this with power menu.
Comment | File | Size | Author |
---|---|---|---|
#6 | content_menu-compatibility_with_power_menu-2383375-6.patch | 1.4 KB | generalredneck |
#4 | content_menu-compatibility_with_power_menu-2383375-4.patch | 574 bytes | micnap |
#3 | compatibility_with_power_menu-2383375-3.patch | 488 bytes | callinmullaney |
#1 | content_menu-power_menu-2383375-1.patch | 618 bytes | jmuzz |
Comments
Comment #1
jmuzz CreditAttribution: jmuzz commentedThe patch.
Comment #2
jmuzz CreditAttribution: jmuzz commentedThis one should be applied to power menu. It removes some functionality but the menu edit form can not be submitted without this change.
Comment #3
callinmullaney CreditAttribution: callinmullaney at Four Kitchens commentedThank you jmuzz for the patch. I know this is an old issue but this specific use case came up recently for a client. I've re-rolled the patch against the latest dev so we can apply via composer. This appears to resolve the incompatibility we were experiencing prior to the patch.
Also, the power menu patch attached in #2 is no longer necessary. That line is active in the latest beta release of that module.
Comment #4
micnap CreditAttribution: micnap at Four Kitchens commentedAdding to Callin's patch:
When a new translation for a menu item's content gets saved, the ENTIRE link array was getting saved to the session and was causing a fatal error. Since only one small piece of the array - the created timestamp - gets used, there's no need to save the entire array. This patch changes what gets saved in the session to just the created timestamp.
Comment #5
generalredneckSo your patch doesn't actually save to the session. This line
Actually saves to a variable that is the contents of
$_SESSION
since you are using the variable variable syntax of$$
That said, this should also fatal if the variable starts with a number, is null, or violates a number of other rules... In this case it's likely creating a variable named $Array
Additionally, if you DID mean to use variable variable, you have an issue with ambiguity here... Here's an excerpt from the PHP manual
see https://www.php.net/manual/en/language.variables.variable.php
Comment #6
generalredneckThe whole point of the code we are changing is strictly to set a class on a row in a table. That said, we don't need to save anything about the Menu Link at all... so I simplified the code and fixed the variable variable typo as well.
We run across a problem that a translation entity was still linked to the menu item, so this isn't a "power menu" specific problem. $link was still being stored to the session for all patches before #4 which caused problems with the session being unserialized like indicated in the original description.
Since the $link isn't being used fro any other reason than to see if the created time was within the 60 second window to highlight the table row green, I just changed the code where we wouldn't have to even worry about the extraneous key or store any piece of $link to the session at all.. Just imply store the created time directly to the session to avoid any of the issues here.