Cached pages give "call to undefined function" error

David_Rothstein - February 25, 2008 - 20:25
Project:Visibility API
Version:5.x-1.2-1
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Description

I'm using Visibility API with caching enabled (normal caching, not aggressive). I found that whenever you log out and visit a cached page, you get a white screen of death with this error message:

Fatal error: Call to undefined function drupal_add_js() in /web/sites/all/modules/visibility_api/visibility_api.module on line 13

The problem is that in Drupal 5, drupal_add_js() should not be called in hook_init() since this function is not available on cached pages. See http://api.drupal.org/api/function/hook_init/5.

Here is a patch that fixes this by moving the code to hook_menu(), as suggested on that page. You may want to try a different solution instead, but this fixes the bug.

Thanks!

AttachmentSize
visibility_api_hook_init.patch768 bytes

#1

tjholowaychuk - February 27, 2008 - 01:07
Status:needs review» fixed

Sorry about that! I am aware of that issue but I have a nasty habit of adding js in init(); even today haha

#2

Anonymous (not verified) - March 12, 2008 - 01:11
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.