Index: browscap.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/browscap/browscap.module,v retrieving revision 1.6.2.3.2.6 diff -u -r1.6.2.3.2.6 browscap.module --- browscap.module 8 Jun 2009 11:37:43 -0000 1.6.2.3.2.6 +++ browscap.module 8 Jun 2009 11:48:32 -0000 @@ -86,18 +86,19 @@ function browscap_exit() { // If monitoring is enabled, record the browser if (variable_get('browscap_monitor', FALSE)) { - $browser = browscap_get_browser(); - $browserstring = substr(trim($browser['parent']), 0, 255); - if ($browserstring == '' or $browserstring == 'Default Browser') { - $browserstring = trim($_SERVER['HTTP_USER_AGENT']); - } - db_query("UPDATE {browscap_statistics} SET counter = counter + 1, is_crawler=%d ". - "WHERE parent='%s'", $browser['crawler'], $browserstring); - // If we affected 0 rows, this is the first time we've seen this browser - if (!db_affected_rows()) { - // We must create a new row to store counters for the new browser. - db_query('INSERT INTO {browscap_statistics} (parent,counter,is_crawler) '. - "VALUES('%s', 1, %d)", $browserstring, $browser['crawler']); + if ($browser = browscap_get_browser()) { + $browserstring = substr(trim($browser['parent']), 0, 255); + if ($browserstring == '' or $browserstring == 'Default Browser') { + $browserstring = trim($_SERVER['HTTP_USER_AGENT']); + } + db_query("UPDATE {browscap_statistics} SET counter = counter + 1, is_crawler=%d ". + "WHERE parent='%s'", $browser['crawler'], $browserstring); + // If we affected 0 rows, this is the first time we've seen this browser + if (!db_affected_rows()) { + // We must create a new row to store counters for the new browser. + db_query('INSERT INTO {browscap_statistics} (parent,counter,is_crawler) '. + "VALUES('%s', 1, %d)", $browserstring, $browser['crawler']); + } } } } @@ -254,13 +255,14 @@ //$browserinfo->tables = $browserinfo->htmltables; cache_set($cacheid, $browserinfo, 'cache_browscap'); } - $info = unserialize($browserinfo->data); - $info['useragent'] = $useragent; - $info['browser_name_pattern'] = strtr($browserinfo->useragent, '%_', '*?'); - return $info; + if (isset($browserinfo) && isset($browserinfo->data)) { + $info = unserialize($browserinfo->data); + $info['useragent'] = $useragent; + $info['browser_name_pattern'] = strtr($browserinfo->useragent, '%_', '*?'); + return $info; + } } - // A numeric interpretation of browscap.csv's TRUE/FALSE/default fields function _browscap_boolean($value) { switch ($value) {