Posted by jupiterchild on February 4, 2007 at 7:07pm
| Project: | Hovertips and Clicktips |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Fatal error: Call to undefined function: drupal_add_css() in /familyhistoryjournal/cms/sites/all/modules/hovertip/hovertip.module on line 61
Installed on 2 sites running Drupal 5.0. Works OK for a time then returns the error above.
Comments
#1
Any ideas on this? Anyone else had this problem?
The module operates OK for a time but intermittently terminates with the aforementioned fatal error message. I have to reinstall the module each time to recover from the error.
I found this is a really useful module to use with larger images. Does not take up real estate but can provide additonal information about an image on demand.
#2
I now realise this happens when I logout as a user with admin role. Immediately I logout I recieve 'Fatal error: Call to undefined function: drupal_add_css()' and Drupal bombs out.
The logs show:
access denied 18 Feb 2007 - 12:10pm sites/all/modules/hovertip/hovertip.js Anonymous
access denied 18 Feb 2007 - 12:10pm sites/all/modules/hovertip/hovertip.css Anonymous
So I guess there is some wierd access control behaviour going on here.
#3
I get this behavior also. What have you done (if anything) to get around this?
#4
I can't reproduce. Need more info. It seems odd that drupal_add_css would ever not be defined, as it should be in common.inc.
Could somebody try changing hovertip_init to be something like:
<?php/**
* Implemention of hook_init in which we load the necessary javascript and stylesheet files.
*/
function hovertip_init() {
if (function_exists('drupal_add_css')) {
drupal_add_css(drupal_get_path('module', 'hovertip').'/hovertip.css');
drupal_add_js(drupal_get_path('module', 'hovertip') . '/hovertip.js');
drupal_add_js(_hovertip_get_javascript(), 'inline');
} else {
print_r(debug_backtrace());
}
}
?>
then post the debug_backtrace() result here?
#5
This is the ouput of the debug:
Array ( [0] => Array ( [function] => hovertip_init [args] => Array ( ) ) [1] => Array ( [file] => /home/fredblogs/public_html/www.example/cms/includes/module.inc [line] => 386 [function] => call_user_func_array [args] => Array ( [0] => hovertip_init [1] => Array ( ) ) ) [2] => Array ( [file] => /home/fredblogs/public_html/www.example/cms/includes/bootstrap.inc [line] => 443 [function] => module_invoke [args] => Array ( [0] => hovertip [1] => init ) ) [3] => Array ( [file] => /home/fredblogs/public_html/www.example/cms/includes/bootstrap.inc [line] => 860 [function] => bootstrap_invoke_all [args] => Array ( [0] => init ) ) [4] => Array ( [file] => /home/fredblogs/public_html/www.example/cms/includes/bootstrap.inc [line] => 819 [function] => _drupal_cache_init [args] => Array ( [0] => 5 ) ) [5] => Array ( [file] => /home/fredblogs/public_html/www.example/cms/includes/bootstrap.inc [line] => 772 [function] => _drupal_bootstrap [args] => Array ( [0] => 5 ) ) [6] => Array ( [file] => /home/fredblogs/public_html/www.example/cms/index.php [line] => 13 [function] => drupal_bootstrap [args] => Array ( [0] => 7 ) ) )
Warning: Cannot modify header information - headers already sent by (output started at /home/fredblogs/public_html/www.example/cms/sites/all/modules/hovertip/hovertip.module:66) in /home/fredblogs/public_html/www.example/cms/includes/bootstrap.inc on line 523
Warning: Cannot modify header information - headers already sent by (output started at /home/fredblogs/public_html/www.example/cms/sites/all/modules/hovertip/hovertip.module:66) in /home/fredblogs/public_html/www.example/cms/includes/bootstrap.inc on line 524
Warning: Cannot modify header information - headers already sent by (output started at /home/fredblogs/public_html/www.example/cms/sites/all/modules/hovertip/hovertip.module:66) in /home/fredblogs/public_html/www.example/cms/includes/bootstrap.inc on line 527
Warning: Cannot modify header information - headers already sent by (output started at /home/fredblogs/public_html/www.example/cms/sites/all/modules/hovertip/hovertip.module:66) in /home/fredblogs/public_html/www.example/cms/includes/bootstrap.inc on line 528
Warning: Cannot modify header information - headers already sent by (output started at /home/fredblogs/public_html/www.example/cms/sites/all/modules/hovertip/hovertip.module:66) in /home/fredblogs/public_html/www.example/cms/includes/bootstrap.inc on line 536
Warning: Cannot modify header information - headers already sent by (output started at /home/fredblogs/public_html/www.example/cms/sites/all/modules/hovertip/hovertip.module:66) in /home/fredblogs/public_html/www.example/cms/includes/bootstrap.inc on line 544
#6
Ok, that was very hard to read, but informative nonetheless. Turns out hook_init is not what I thought it was, and in the hook_init documentation they recommend using hook_menu instead. Not intuitive, but I think it will fix the problem if the code from my hook_init is moved to hook_menu.
No time for me to produce a patch this second, but perhaps tomorrow. Thanks for the added info.
#7
If anyone has the actual changes that need to be made to make this work, please post it. Otherwise, the only way I found to get around this problem is to disable caching mode (Administer -> Site configuration -> Performance).
#8
I am having the same problem and would like to see the changes too. Subscribing so I can track this post.
#9
i've done recently the same patch for my jtooltips module. It is simply:
change your hovertip_menu in:
<?php
function jtooltips_menu($may_cache) {
$items = array();
if ($may_cache){
$items[] = array('path' => 'admin/settings/hovertip',
'title' => t('Hovertip settings'),
'description' => t('Configure the hovertip module'),
'callback' => 'drupal_get_form',
'callback arguments' => 'hovertip_settings_form',
'access' => user_access('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);
}
else {
drupal_add_css(drupal_get_path('module', 'hovertip').'/hovertip.css');
drupal_add_js(drupal_get_path('module', 'hovertip') . '/hovertip.js');
drupal_add_js(_hovertip_get_javascript(), 'inline');
}
return $items;
}
?>
#10
ops, the function calls hovertip_menu(), while you should delete also hovertip_init()
#11
Thanks for the help. This seems like a simple enough change, and I'll commit it when I can. I'm travelling and may not have a chance for a week or so...
#12
I've checked in the attached patch. I was never able to reproduce the problem. Still I hope this will fix it.
Thanks for the advice.
#13
#14
I have got the same error in dropdown_menu.module on line 5:
Fatal error: Call to undefined function drupal_add_css() in /home/gaultmi/public_html/modules/dropdown_menu/dropdown_menu.module on line 5The funny thing is, this PHP error only occurs in FireFox! Not in IE. After refreshing FireFox 3-4 times, it does load. Then it goes back to the error again.
This is from dropdown_menu.module:
function dropdown_menu_init() {
drupal_add_css(drupal_get_path('module', 'dropdown_menu').'/dropdown_menu.css');
drupal_add_js("
$(function(){
$('.dropdown_menu li').hover(
function () {
$(this).addClass('sfhover');
},
function () {
$(this).removeClass('sfhover');
}
);
});
", 'inline');
}
Any help?
#15
Also, it only happens in FireFox, but only when CACHE is on NORMAL in admin/settings/performance. When I turn off cache, the error never occurs.
#16
mxistance, from your comments, it sounds like your problem is with dropdown_menu.module. Are you also getting the same error with hovertips.module?
If not, please submit a new issue to the dropdown_menu issue queue, rather than opening a closed issue here. Thanks
#17
I would not say, that this is a problem of hovertips and clicktips, as it also occurs with the iconify.module, not having dropdown_menu.module or hovertips or clicktips installed.
By the way, this error did not occur with cache set to disabled, only if cache is set to normal. Further more, this error seems to be only appearing, when calling http://www.MyDomain.com/ . When calling http://www.MyDomain.com/index.php, the error does not occur.
I'll try to dig into iconify.module to find out more ....
#18
As far as I can see it by now, drupal_add_css (or drupal_add_js) cannot be called reliably through both hook_init() or hook_menu() - if caching is set to normal.
That a reliable call to drupal_add_css() is not possible in hook_init() is already mentioned in hovertip module ....
#19
I think its unrelated to hovertip module itself.
But isn't it amazing PHP errors can occur differently by browser type? That's supposed to be impossible, yet this error never occurs in IE6-IE8, only in Safari/Firefox with cache set to Normal.
#20
Sounds like the browsers are making different requests of the server, based on their caching behavior. That would explain why the server does different things for different browsers.
Let me know if this is still an issue for hovertips. Sounds like its not.
#21
Automatically closed -- issue fixed for 2 weeks with no activity.