iPad coming to our site (ebmud.com) fails with error:
"PHP Notice: Undefined index: parent in x:\.......browscap.module on line 85"

Acquia Drupal running on win2008 server/IIS7 - it could be our setup....

CommentFileSizeAuthor
ipadFail.JPG221.79 KBmuddum

Comments

greggles’s picture

A PHP notice should not cause your server to stop processing the page unless there is some further problem with your setup (or with iPad's processing of HTTP headers, which seems unlikely).

All the same, Drupal's code should be E_ALL compliant and these are usually easy bugs to fix so...if you can provide a patch I'd be happy to review/commit.

muddum’s picture

FYI - this now is not just for iPad - but for Safari 5.0 on Mac and Windows as well......

Ok, I set the error_reporting = E_ALL in php.ini and then altered the browscap.module so:

....
function browscap_exit() {
  // If monitoring is enabled, record the browser
  if (variable_get('browscap_monitor', FALSE)) {
    if ($browser = browscap_get_browser()) {
	   //add code to ensure var is set.............................................
	   if (!isset($browser['parent'])) 
		{$browser['parent'] = 'Default Browser';}
           //all the same from here down...............................................
      $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']);
      }
    }
  }
}
...

That seems to have fixed it but I am a complete newbie to PHP and Drupal so I suspect that this is completely wrong. However - IF this is the correct way to go it is very exciting as it is my first contribution back to the Community!

greggles’s picture

Thanks for your bug report and for helping make this a better module. Could you provide this as a patch?

greggles’s picture

Title: iPad fails with browscap error » Safari 5.x causes php notice in browscap

A better title.

brycesenz’s picture

I am actually getting this same error on my machine as well (Ubuntu Meerkat, Apache, mySQL, PHP5). I am running the latest version of Drupal and the latest -dev version of Browscap. In my case, there are actually three errors that keep coming up in sequence:

PHP Notice:  Undefined index:  HTTP_USER_AGENT in ...modules/browscap/browscap.module on line 253

PHP Notice:  Undefined index: parent in ...modules/browscap/browscap.module on line 85

PHP Notice:  Undefined index:  HTTP_USER_AGENT in ...modules/browscap/browscap.module on line 87

These errors don't seem to have any detrimental effect on the rest of the site's functionality, but it's still less than ideal that they keep coming up.

venusrising’s picture

Did anyone ever find a fix to line 253? This issue is from March which is 4 months old now. The module works great but this printing the error in a live site is bad news.

devin carlson’s picture

Version: 6.x-1.1 » 7.x-1.x-dev
Status: Active » Fixed

I believe this issue has been fixed by #1012924: Getting pages with CURL, php notice.

To test this, download the latest dev version of Browscap and clear the existing Browscap logs (unfortunately, until #810502: Purge data button is completed this will need to be done manually, such as by uninstalling Browscap).

If anyone is still receiving errors feel free to reopen this issue.

Status: Fixed » Closed (fixed)

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