ip2locale wouldn't for me. I tried both ip2country and ip2cc backends, with no luck. I also tried disabling, uninstalling and reinstalling both the stable and the dev versions. Nothing does it.

The only results I've got so far is these errors in the log:

[Sat Mar 13 23:55:07 2010] [error] [client 72.30.161.253] PHP Notice: Undefined variable: redirect in /var/www/vhosts/somesite.com/httpdocs/sites/all/modules/ip2locale/ip2locale.module on line 241

[Sun Mar 14 00:08:57 2010] [error] [client 67.195.37.156] PHP Notice: Undefined index: ip2locale_lc in /var/www/vhosts/somesite.com/httpdocs/sites/all/modules/ip2locale/ip2locale.module on line 176

[Sun Mar 14 00:08:57 2010] [error] [client 67.195.37.156] PHP Notice: Undefined index: q in /var/www/vhosts/somesite.com/httpdocs/sites/all/modules/ip2locale/ip2locale.module on line 209

[Sun Mar 14 00:08:57 2010] [error] [client 67.195.37.156] PHP Notice: Undefined variable: redirect in /var/www/vhosts/somesite.com/httpdocs/sites/all/modules/ip2locale/ip2locale.module on line 241

[Sun Mar 14 00:08:57 2010] [error] [client 67.195.37.156] PHP Notice: Undefined variable: redirect in /var/www/vhosts/somesite.com/httpdocs/sites/all/modules/ip2locale/ip2locale.module on line 241

[Sun Mar 14 00:08:57 2010] [error] [client 67.195.37.156] PHP Notice: Undefined variable: redirect in /var/www/vhosts/somesite.com/httpdocs/sites/all/modules/ip2locale/ip2locale.module on line 241

[Sun Mar 14 00:09:07 2010] [error] [client 67.195.37.156] PHP Notice: Undefined index: ip2locale_lc in /var/www/vhosts/somesite.com/httpdocs/sites/all/modules/ip2locale/ip2locale.module on line 176

[Sun Mar 14 00:09:07 2010] [error] [client 67.195.37.156] PHP Notice: Undefined variable: redirect in /var/www/vhosts/somesite.com/httpdocs/sites/all/modules/ip2locale/ip2locale.module on line 241

[Sun Mar 14 00:09:07 2010] [error] [client 67.195.37.156] PHP Notice: Undefined variable: redirect in /var/www/vhosts/somesite.com/httpdocs/sites/all/modules/ip2locale/ip2locale.module on line 241

[Sun Mar 14 00:09:07 2010] [error] [client 67.195.37.156] PHP Notice: Undefined variable: redirect in /var/www/vhosts/somesite.com/httpdocs/sites/all/modules/ip2locale/ip2locale.module on line 241

Please help.

Comments

Gabriel R.’s picture

The one Backend I didn't try yet is the GeoIP API module. Is it worth trying it out?

Gabriel R.’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

Gabriel R.’s picture

Status: Closed (fixed) » Active

The errors disappeared from the web pages, but it still lurks under the hood.

It actually breaks Drush for me. Here is what 'drush -d cron' reports:

Undefined index: ip2locale_lc ip2locale.module:176 [0.11 sec, 6.26 MB] [notice]
Trying to get property of non-object ip2locale.module:464 [0.11 sec, 6.26 MB] [notice]
Undefined index: ip2locale.module:485 [0.11 sec, 6.27 MB] [notice]
Undefined index: q ip2locale.module:210 [0.11 sec, 6.26 MB] [notice]
Undefined variable: redirect ip2locale.module:242 [0.11 sec, 6.27 MB] [notice]

If the ip2locale module is disabled, Drush works again.

Gabriel R.’s picture

Disabling and re-enabling the module does not fix the issue.

Gabriel R.’s picture

OK, so I just realized that this has nothing to do with the DB: index here is not about a table but just some innocent PHP notice about an array index.

I am not even sure if this is the precise issue that breaks Drush, but it's pretty obvious that ip2locale is the culprit.

Any help would be appreciated.

Gabriel R.’s picture

Category: support » bug
Status: Active » Needs review

OK, I figured it out. The same way you check if the current page is cron or update, you much check that you are not running from CLI.

To fix this, check for $_SERVER['SERVER_ADDR']. Add the check at the beginning of ip2locale_boot() like so:

function ip2locale_boot() {

  // Do not redirect if we are running from the command line
  if (empty($_SERVER['SERVER_ADDR'])) return FALSE;
mrfelton’s picture

Status: Needs review » Fixed

#741778 by Gabriel Radic: Fixed Undefined variable: redirect; Undefined index: ip2locale_lc();.

Thanks.

Status: Fixed » Closed (fixed)

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

jonathanpglick’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new1.63 KB

Not sure if anyone is still having problems with this but I created a patch that resolves a few of the PHP warnings and notices that was keeping this module from working for me.

Fixes:

- $_REQUEST['q'] won't be set on homepage
- $redirect can be undefined
- undefined index error with $custom_mappings[$cc]
- undefined index error with isset($_GET['ip2locale_debug'])