Closed (fixed)
Project:
DHTML Menu
Version:
7.x-1.x-dev
Component:
PHP Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
7 Jan 2009 at 13:29 UTC
Updated:
18 Apr 2009 at 07:40 UTC
Jump to comment: Most recent file
Comments
Comment #1
cburschkaI don't think that's my fault. Your theme is somehow sneaking a function into the theme registry that it then fails to implement. Try rebuilding your theme registry or changing your theme.
Comment #2
deepak@1your.com commentedhmm...
My theme is a Genesis theme customisation.
I did clear my cache but it did not fix this issue. The strange thing is everything worked spot-on with the previous version 6.x-3.2 and my problem started only appearing in this release 6.x-3.3. Does that imply - some change in this release has either broken something or has caused an existing bug to highlight?
As I don't have enough knowledge to understand the implications of the recent fixes, I am not sure where to look.
Thanks any ways for replying...
Deepak
www.1your.com/drupal
Comment #3
cburschkaFrom the 3.3 release notes:
Before 3.3, DHTML Menu simply stopped themes from implementing the theme_menu_item(_link) functions. If a theme implemented these, they were never called as DHTML Menu replaced them with its own functions.
Now, DHTML Menu remembers the functions it replaces, and makes sure to call them once it's done with its own stuff.
For some reason, your theme registry contains a function named genesis_menu_item_link even though this function does not actually exist. I'll check how the theme registry is built to find out why this is happening. It might still be a bug in DHTML Menu...
Comment #4
cburschkaPlease check your modified version of the genesis template.php file for the function "genesis_theme".
In this function, you return an array that probably contains an element with the key "menu_item_link". Please remove or comment out this element, rebuild your database caches, and see if you still get this error.
Comment #5
deepak@1your.com commentedLooked at my modified template.php and found no explicit references to menu_item_link.
One thing I forgot to mention is that I have 'Garland' as my admin theme and these errors happened only when I go from the Genesis theme to the Garland theme. My Genesis theme has the function 'genesis_menu_item_link' defined where as the Garland theme doesn't. Going by this fact, I removed this function declaration from my Genesis Base template.php and this error stopped happening. I was able to go from the Genesis theme to the Garland theme without the problem I mentioned above.
How ever looking at my 'Recent log entries', I see this error message
'Invalid argument supplied for foreach() in /home/cyour3/public_html/drupal/includes/menu.inc on line 736.'
every time I refresh the page in the Garland theme.
ATM, I have reverted back to the earlier version of the DHTML Menu module...
Thanks for your help.
Deepak
www.1your.com/drupal
Comment #6
cburschkaThat changes everything. It's my fault after all. ;)
DHTML Menu uses a single variable to store the function it "overrides" - but logically, this does not work when multiple themes are used on the same site. I expect that the same bug will be experienced on sites where the user can pick their own theme.
I'll have a patch ready in a bit.
Comment #7
cburschkaThe underlying problem goes deeper than this. theme_registry_alter is not made aware of which theme is being processed, which is imho an annoying failing of the theme API. It makes it impossible to do this perfectly.
Instead, the stop-gap measure is to make only one attempt to find the overriding theme function, and revert to the base theme function if it is not found. This will stop the fatal error, but could cause unpredictable behavior when multiple themes are used on a site and more than one of them implements menu_item or menu_item_link.
Comment #8
deepak@1your.com commentedthat was fast! Thanks very much for your effort...
I applied the patch and can confirm that I can now switch between the two themes without any major problems...
however I am still noticing error statements in my 'Recent Log Entries'
"Invalid argument supplied for foreach() in /home/cyour3/public_html/drupal/includes/menu.inc on line 736."
Everytime I jump from the Genesis theme to the garland theme... and this stops when I revert back to the previous version...
Can once again use your magic wand to produce a patch for this as well?
Thanks,
Deepak
www.1your.com/drupal
Comment #9
cburschkaThere is only one part of my code that calls menu_tree_output... assuming that the error is the only problem, it should be sufficient to make sure that the argument is always an array.
Comment #10
deepak@1your.com commentedExcellent! Have applied this patch and can confirm that there are no more errors logged. I am really pleased with the support I have received regarding this issue and thanks very much - Arancaytar for your prompt actions.
Thanks,
Deepak
www.1your.com/drupal
Comment #11
cburschkaI wouldn't commit on a single review normally, but I know what the change does and don't expect any regressions. At most, some remaining weirdness in the above-mentioned special cases, but nothing worse than the fatal errors it fixes. So, committed to DRUPAL-6--3.
I'll have a release out soon, once I fix the other few bugs in the queue.
Comment #12
manuel garcia commentedI have successfully applied this patch, and it got rid of the error.
Thanks!
Comment #13
manuel garcia commentedsorry... we replied at the same time it seems :X
Comment #14
Stef01 commentedHad the same problem with zen theme ("Call to undefined function zen_menu_item_link()") and Garland as admin theme.
The patch solved the problem.
Thanks.
Comment #15
cburschkaHeh... normally I have to wait weeks before my patch gets reviewed, and now I get two reviews the moment I commit the patch. :)
Comment #16
manuel garcia commentedIt seems there's still a problem with this, let me explain:
I've tested a bit, if we switch theme (we're using garland for admin pages, which doesn't have a custom function), and then switch to the theme that has the custom function, it doesn't get picked up, and the menu is rendered again by default. If you then empty the cache, the theme function gets picked up and is displayed accordingly. Looks like there's a problem with the way that dhtml_menu updates what function to use, though not being a developer it totally eludes me.
Let me know if you need more information or further testing, this is a critical issue for our site :)
Information that might help out narrow down the issue:
This runing the 6.x-3.3 version with the patch dhtml_menu-theme_function_exists-355521-9.patch applied.
Below the functions we're using the functions: abacus_menu_item_link() and abacus_menu_item():
Comment #17
cburschkaOh. Right. :(
I knew there was a flaw, but I thought the conditions were rarer.
I need to go back to the drawing board and the theme API. Surely there must be some way I can tell in the alter hook which theme is being altered...
Comment #18
cburschkaThat was surprisingly simple, which makes my earlier flawed solution all the sillier. ;)
I completely forgot that the name of the active theme is in the global namespace. "global $theme", and suddenly I know exactly which theme function to call.
Here is the patch. It requires the theme registry to be rebuilt, of course - before the version is released as stable, I will create an update function that does this and removes the old system variables.
Edit: Note that this version applies to what is in CVS, so it rolls back the committed patch.
Comment #19
cburschkaStupid typos. >_<
Comment #20
manuel garcia commentedOK, so applied the second patch to the already patched version, here is what it spitted out:
Looks like it didn't apply properly... any chance we can get a patch for the current version? Or did i do something wrong here?
Comment #21
manuel garcia commentedNevermind!!
Seems like one of our developers had previously touched the module :S I've re-done the whole process, and it seems like the bug is now gone. Please people confirm :)
Comment #22
cburschkaThat's great. Thanks for testing this! :)
Comment #23
cburschkaHere comes the update path (which is really just housekeeping). I'll give this a last minute testing and see if it works.
Comment #24
cburschkaEr... yes.
Comment #25
cburschkaCommitted, tagged, released!
Comment #26
manuel garcia commentedAwesome, thanks a lot Arancaytar... I'll update the module today :)
Comment #28
cburschkaStill needs to be fixed in 7.x-1.x-dev.
I've ported the patch from #23 so that it applies to my version of HEAD. Here we go.
Comment #29
cburschkaI removed the hook_theme implementation pre-commit. This is part of a pending dhtml_menu change that allows custom labels on items, and it shouldn't be in CVS until that change actually happens.
It already worked in the stable version, so I've committed the change to the unstable 7.x-1.x-dev branch without a second review.