Download & Extend

all to undefined function url()

Project:ipAuthenticator
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Fatal error: Call to undefined function url() in /var/www/sites/all/modules/ipAuthenticator/ipauth.module on line 42

I keep getting this error when trying to use the IP Authenticator module. Any thoughts?

Comments

#1

I did not get this error until I updated to the latest Drupal 6.16 version, then I got this error. Turning off caching fixes the error but I'd rather not have to turn off caching.

#2

You shouldn't have to turn off the caches, just clear them.

Simply go to Administer > Site configuration > Performance. Near the bottom of the page, you'll see a big fat button that says “Clear cached data.”

Good to go!

#3

Priority:critical» normal
Status:active» fixed

#4

Did that several times, still get the error.

#5

You sure your getting the same exact error?

#6

Yes, same exact error. Only for the IPAuthenticated user, regular login works fine.

#7

Status:fixed» active

We are receiving the same message: Fatal error: Call to undefined function url() in /var/www/html/sites/all/modules/ipAuthenticator/ipauth.module on line 42

I have tried clearing the cache and still get the error. Unlike b0b, if I turn off caching, I get many more errors (though this particular one goes away).

We also recently updated to Drupal 6.16.

I'm changing status to active (though I'm a newbie, so let me know if that is wrong).

Any help is greatly appreciated.

#8

Im no expert but wile your waiting for an educated response, you could disable the module and uninstall it from drupal. Re-download it and put it back up on your site again. Just remember your current settings and re-enter them into the module after you reinstall it.

Also, make sure you disable the module then uninstall it, that way drupal will remove the tables from the database. However; if you have alot of groups/imported users or something you may not be able to do this.

Let me know what you come up with!

#9

To get around this problem, I added the following lines before the call to url()
include_once './includes/common.inc';
include_once './includes/path.inc';

I don't get how url() would ever work in ipauth_boot() as at this point the boot loader hasn't included common.inc where url() is defined.

Also, on the home page $_GET["q"] isn't defined, so around line 72 I added this line:
if (!isset($_GET['q'])) $_GET['q']='';
before
if ($_GET['q'] == 'user')

otherwise that line bombs.

Not sure if I solved the root of this problem, but these fixes worked for me.

#10

I just wanted to say thanks. mhennings fix worked for me.
Thanks jhus for the response too.

#11

I am having the same problem. When I disable caching it works though. I do not know where I apply the lines that mhenning proposed.

Am I supposed to apply these two lines:
include_once './includes/common.inc';
include_once './includes/path.inc';

at line 42 before the line:
url($_GET["q"], 'ipauth_no_cache='.md5(time()), NULL, TRUE);

Can someone help me out please?

Thank you!
This mod is great btw!!!

#12

They should generally be at the top of the code. The include_once() statement includes and evaluates the specified file during the execution of the script. Meaning you ideally want it loaded before you do anything.

#13

tways,
I'm copying the code around where mhenning inserted changes (which are noted in the comments as changes by saforian). I'm not a programmer, so hopefully I grabbed everything right (looks like some of the tabs gets messed up when I preview the code).
Hope this helps!

      if (variable_get('cache', CACHE_DISABLED) != CACHE_DISABLED && !isset($_GET['ipauth_no_cache'])) {
        // Reload the page, the query string ensures that there will be a page
        // cache miss and thus a fresh generated page is served.

//SAFORIAN add this so url() works
include_once './includes/common.inc';
include_once './includes/path.inc';  
$url = url($_GET["q"], array('query'=>'ipauth_no_cache='.md5(time())));
//old version that honestly I don't know how it ever worked without includes and format is wrong for D6
//$url = url($_GET["q"], 'ipauth_no_cache='.md5(time()), NULL, TRUE);

        // Remove newlines from the URL to avoid header injection attacks.
        $url = str_replace(array("\n", "\r"), '', $url);

        // Before the redirect, allow modules to react to the end of the page request.
        module_invoke_all('exit', $url);

        // Even though session_write_close() is registered as a shutdown function, we
        // need all session data written to the database before redirecting.
        session_write_close();

        header('Location: '. $url, TRUE, 302);
        exit();
      }
    }
  }

//SAFORIAN add the 0 here so this code won't be run and you can login
  if (0 || in_array($user->uid, ipauth_get_uids('enabled'))) {
    // It's one of the special ip_auth users, take the authenticated user role away.
    unset($user->roles[DRUPAL_AUTHENTICATED_RID]);
    $user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';

//SAFORIAN, add this so calls down below don't bomb on home page where q isn't set
if (!isset($_GET['q'])) $_GET['q']='';

    if (!_ipauth_path_allowed()) {
      drupal_access_denied();
      // Allow modules to react to the end of the page request.
      module_invoke_all('exit');
      exit();
    }