During the initial parsing of the MaxMind CSV, the Watchdog log fills up with many notices - "Notice: Trying to get property of non-object in smart_ip_update_database() (line 328 of .../sites/all/modules/smart_ip/includes/smart_ip.utility.inc)."

Actually, what is happening is that cache_get() on line 311 is failing to return an object from the cache and each reference to $location is throwing a "non-object" error. Because of this my Watchdog log ends up with millions of errors.

The CSV source from MaxMind that I am using is:
http://geolite.maxmind.com/download/geoip/database/GeoLiteCity_CSV/GeoLi...

I may be misreading this but why does cache_set() on line 242 use "$data[0]" when cache_get() on 311 use "$data[2]" when creating its cid?

I am using 2.0, the module datestamp = "1364269218"

Comments

arpeggio’s picture

Status: Active » Fixed

Hi, I have already fixed this issue. Please use dev version. Thank you for reporting this issue.
The cache_set() on line 242 use "$data[0]" targets the locId column of file GeoLiteCity-Location.csv:

Copyright (c) 2012 MaxMind LLC.  All Rights Reserved.
locId,country,region,city,postalCode,latitude,longitude,metroCode,areaCode
1,"O1","","","",0.0000,0.0000,,
2,"AP","","","",35.0000,105.0000,,
... and so on

...and cache_get() on 311 use "$data[2]" also targets the locId column of file GeoLiteCity-Blocks.csv:

Copyright (c) 2011 MaxMind Inc.  All Rights Reserved.
startIpNum,endIpNum,locId
"16777216","16777471","17"
"16777472","16777727","104084"
... and so on
jschrab’s picture

Version: 7.x-2.0 » 7.x-1.x-dev
Status: Fixed » Needs work

I am afraid I am still seeing seeing errors by the thousands...

Notice: Trying to get property of non-object in smart_ip_update_database() ...

...within the try/catch block. I am using the current May 20th dev version.

arpeggio’s picture

Status: Needs work » Fixed

Hi, I have added condition to check if the data object element is set:

      if (isset($location->data['country_code'])) {
        try {
          // Insert GeoIP into the temporary working Smart IP database table
          db_insert('smart_ip_update_table')
            ->fields(array(
              'geoip_id',
              'ip_ref',
              'country_code',
              'region',
              'city',
              'zip',
              'latitude',
              'longitude',
            ))
            ->values(array(
              'geoip_id'     => $data[2],
              'ip_ref'       => min($data[0], $data[1]),
              'country_code' => strtoupper($location->data['country_code']),
              'region'       => strtoupper($location->data['region']),
              'city'         => $location->data['city'],
              'zip'          => $location->data['zip'],
              'latitude'     => $location->data['latitude'],
              'longitude'    => $location->data['longitude'],
            ))
            ->execute();
        }
        catch(Exception $error) {
          db_update('smart_ip_update_table')
            ->fields(array(
              'geoip_id'     => $data[2],
              'country_code' => strtoupper($location->data['country_code']),
              'region'       => strtoupper($location->data['region']),
              'city'         => $location->data['city'],
              'zip'          => $location->data['zip'],
              'latitude'     => $location->data['latitude'],
              'longitude'    => $location->data['longitude'],
            ))
            ->condition('ip_ref', min($data[0], $data[1]))
            ->execute();
        }
      }

Please use the dev version. Thank you.

jschrab’s picture

I'm not certain what is happening but now any updates lead to a TOTALLY empty smart_ip table.

arpeggio’s picture

Sorry I missed to update the correct count of columns in "GeoLiteCity-Location.csv". Before:

if (count($data) == 7 && is_numeric($data[0])) {

Correct:

if (count($data) == 9 && is_numeric($data[0])) {

And I have already tested. Please use the dev version. Thanks.

jschrab’s picture

This all does resolve the original issue. However, I think there still is 'smartip' table rebuilding problems (possibly memcache or cache_set/cache_get/cron related). I will launch another issue as soon as I can finish gathering details and properly express the problem I am seeing.

Status: Fixed » Closed (fixed)

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