Fatal error: Call to undefined function: drupal_add_js() in /home/xxx/public_html/sites/all/modules/devel/devel.module on line 166
also log showing sites/all/modules/devel/devel.css not found, even though it is there.

I have drupal 5.1, PHP 4.4.4, apache 1.3.37. only devel module enabled. not node access or macro.

My test machine running drupal 5.1, PHP 5.2, apache 1.3.33 does not have this error.

moving the devel folder out of the module folder allows login. also if logged in, and then logout you can use the back button to the user login and still login without having to move the devel folder.

thanks for all your hard work. this is a great module.

CommentFileSizeAuthor
#1 devel_15.patch432 bytesdave reid

Comments

dave reid’s picture

Assigned: Unassigned » dave reid
Status: Active » Needs review
StatusFileSize
new432 bytes

I'm guessing that since the annonymous users get cached versions, that some functions aren't available. When I added drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); to the beginning of the function devel_init() that anonymous browsing worked correctly. I've attached a patch but I haven't had time to investigate if there are any side-effects.

dsp1’s picture

right, I have Caching mode: Normal on the web site and Caching mode: Disabled on my test site.
I think I will wait to apply the patch to find out if there are any side effects.
thank you for your response.

laken’s picture

subscribing

dave reid’s picture

Status: Needs review » Reviewed & tested by the community

I'm very sure this is ready to commit. I haven't experienced any problems since the patch.

dww’s picture

Status: Reviewed & tested by the community » Needs review

i'm not so sure. take a look at http://drupal.org/node/123951 which is the issue that led to that call to drupal_add_js() being inserted in the first place. i think there might be cases when you break something by always doing a drupal_bootstrap() in hook_init() -- that seems totally wonky to me.

in fact, if you read http://api.drupal.org/api/5/function/hook_init you'll see that adding functions in hook_init() is generally prone to these errors, and when you get them, it recommends moving the offending code to hook_menu(), instead.

honestly, i don't fully understand the implications of #123951 enough to say for sure, but i'm *positive* this at least needs more review, if not more work, before it can be committed...

hopefully moshe and/or ted will reply here with their thoughts...

nicholasthompson’s picture

I've just upgraded www.thingy-ma-jig.co.uk to Drupal 5.1 and this bug was taking the entire site out for anon users. A suggestion by Mike Dixon was to use the user_access() function - so by wrapping the contents of devel_init() in a user_access() call like this...

function devel_init() {    
  if(user_access('access devel information')) {
    // ensure that jquery has been added to the page
    drupal_add_js('', 'inline');
    
    if (strstr($_SERVER['PHP_SELF'], 'update.php') || strstr($_GET['q'], 'autocomplete')) {
      // update.php relies on standard error handler
    }
    else {
      register_shutdown_function('devel_shutdown');
      if (variable_get('dev_mem', 0) && function_exists('memory_get_usage')) {
        global $memory_init;
  
        $memory_init = memory_get_usage();
      }
      $handler = variable_get('devel_error_handler', DEVEL_ERROR_HANDLER_STANDARD);
      switch ($handler) {
        case DEVEL_ERROR_HANDLER_STANDARD:
          // do nothing
          break;
        case DEVEL_ERROR_HANDLER_BACKTRACE:
          set_error_handler('backtrace_error_handler');
          break;
        case DEVEL_ERROR_HANDLER_NONE:
          restore_error_handler();
          break;
      }
    }
  }
}

... the error SEEMS to dissapear...

(I dont have diff facilities available right now)

Any thoughts on this?

nicholasthompson’s picture

ignore me - this is not a fix... It took 10 minutes, but the page broke eventually.

Basically the same error as above.

Gonna try checking the global $user object...

nicholasthompson’s picture

Much better solution (again suggested by Mike Dixon) is this:

if(function_exists('drupal_add_js'))

That should nail it...

dww’s picture

Status: Needs review » Fixed

moshe just removed the line entirely (if you freshly update from CVS), since he didn't think the drupal_add_js() was essential to the other functionality and fixes addressed in http://drupal.org/node/123951

i just tested, and this is already fixed with the latest code (revision 1.106.4.41 of devel.module). with page caching enabled, 1.106.4.40 killed the site for anonymous, and 1.106.4.41 works fine.

dericknwq’s picture

With that line removed, isn't JQuery not included at all? I've enabled viewing of devel information for anonymous user on my test site and that wouldn't work. I think the problem right now is getting Devel to work with the Cache (Normal) turned for Anonymous (with access "access devel information"). Or rather, Devel does not play well with Cache turned on at all.

Anonymous’s picture

Status: Fixed » Closed (fixed)