Today, I've been encountering a problem with my site - it crashes on every page load (sometimes with a PHP out of memory error). After some debugging, I was able to reproduce it from a minimal installation:
1. Install from the minimal profile
2. Enable the bean and bean admin UI module (and it's dependencies)
3. Add a block type
4. Add a block
5. Add this block to the blocks for the theme (used Bartik, footer region)
6. Verify that you can indeed see this Bean on all pages.
7. Enable the title module
8. Watch your site have a heart attack whenever Bartik is used (but not the admin pages)
I'm going to continue to investigate to see if I can narrow down the problem further, but it looks like something in the title module is causing the bean rendering process to use up all the PHP memory and then crash the site (and occasionally my server). Given the timing of this (it was working perfectly fine on builds done last week), I suspect this is something that was changed in title with the alpha7 release.
Anyone have any thoughts what might be causing this?
Update: Confirmed that reverting to alpha5 fixes this problem.
Comment | File | Size | Author |
---|---|---|---|
#9 | entity-label_callback_recursion-1947142-9.patch | 1.26 KB | plach |
#5 | entity-label_callback_recursion-1947142-5.patch | 949 bytes | plach |
#4 | entity-label_callback_recursion-1947142-4.patch | 833 bytes | plach |
Comments
Comment #1
ottawadeveloper CreditAttribution: ottawadeveloper commentedI've narrowed down what's happening but I have no idea who should be fixing it or how:
The title patch added this line (title.module, line 124 about in title_entity_label). Title has changed the label callback of the module to title_entity_label, just for reference, and stored the original callback in the label fallback.
This is called for the bean entity as we are not replacing the title field. For bean the original value is entity_class_label.
This triggers a call to the label() method of the Bean object (which inherit's it's definition from the Entity class). The definition looks like this:
Since the label callback is no longer "entity_class_label" (because title changed it), this places a call to entity_label.
And, as you can imagine, label callback is set to title_entity_label which starts the recursion and memory eating destruction.
It seems like this makes it difficult to override label callback for entities that use entity_label_class if you intend to use entity_label_class as a fallback (and possibly other cases as well).
I imagine the solution to be either altering the fallback to handle this case better or moving this issue over to the Entity module so they can have a more robust method of handling class-based labels without the risk of recursion where the label callback has been overridden (and yet is still used).
Comment #2
plach@ottawadeveloper:
Thanks for the thorough report :)
I'd say the long term solution should be the latter. We can introduce a stop-gap fix in Title to avoid the fallback when the label callback is
'entity_class_label'
, but this would defeat the goal of the original patch in this case. Actually the structure of the fallback key was designed to allow for a fallback chain where every module could deal with only a single override, that is the one it finds in the'label callback'
when its implementation ofhook_entity_info_alter()
is invoked. Perhaps the proper solution could be for Entity to adopt this "standard" and explicitly support the'label fallback'
key.Comment #3
plachNope, probably this won't work, since it is supporting the use case when
$entity->label()
is not the label callback. It's not a matter of fallback. I guess Entity should just provide protection against recursion with a static variable or a class field.Comment #4
plachThe attached patch should do the trick.
Comment #5
plachBetter one
Comment #6
thim CreditAttribution: thim commentedHi Plach,
I can confirm that this issue resolved my error.
Here some more details so that other people can find the issue, in case of same problems.
After upgrading the Title module to Title 7.x-1.0-alpha7 and having Entity API 7.x-1.0 already in use, the following error occured.
[17-Apr-2013 11:46:25] PHP Fatal error: Maximum function nesting level of '200' reached, aborting! in /www/includes/common.inc on line 120
...
[17-Apr-2013 11:46:25] PHP 196. entity_class_label() /www/sites/all/modules/contrib/title/title.module:132
[17-Apr-2013 11:46:25] PHP 197. Entity->label() /www/sites/all/modules/contrib/entity/entity.module:1066
[17-Apr-2013 11:46:25] PHP 198. entity_label() /www/sites/all/modules/contrib/entity/includes/entity.inc:125
[17-Apr-2013 11:46:25] PHP 199. title_entity_label() /www/includes/common.inc:7890
The patch of Plach in comment #5 resolved it.
http://drupal.org/node/1947142#comment-7207826
Comment #7
FrancescoQ CreditAttribution: FrancescoQ commentedLooks good and fixes the issue.
Comment #8
fagoThanks, that looks like a good fix. But it might be a bit hard to follow, could we add some comments for explaining what we are doing here?
Comment #9
plachAdded a comment explaining what's happening.
Comment #10
fagoThanks, committed.
Comment #11.0
(not verified) CreditAttribution: commentedUpdate based on my confirmation of which version we can revert to to fix the problem.