Not sure if this is a setup problem unique to our site.
Just updated from browscap-6.x-1.5 to 6.x-2.0 and when fetching browscap data get this error in watchdog.

Error parsing /tmp/browscap_example.com.ini on line 386 in /home/example/public_html/sites/all/modules/browscap/import.inc on line 90.

Any thoughts on how to fix this would be appreciated.
Thanks.

CommentFileSizeAuthor
#8 browscap-update_data_url-1852184-8.patch632 bytestedbow

Comments

bacchus101’s picture

I'm also getting this error on Drupal 7 running PHP 5.2.17.

toomanypets’s picture

I have the same problem with PHP 5.2.17 (browscap module version 7.x-2.0).

Per http://tempdownloads.browserscap.com it seems we should be using http://tempdownloads.browserscap.com/stream.php?PHP_BrowsCapINI instead of http://tempdownloads.browserscap.com/stream.php?BrowsCapINI

I modified line 51 of import.inc to resolve the problem.

Before:

$browscap_data = drupal_http_request('http://tempdownloads.browserscap.com/stream.php?BrowsCapINI');

After:

$browscap_data = drupal_http_request('http://tempdownloads.browserscap.com/stream.php?PHP_BrowsCapINI');
toomanypets’s picture

Category: support » bug
izmeez’s picture

@toomanypets Thank you. Fix in #2 works like a charm.

devin carlson’s picture

greggmarshall’s picture

#2 also worked for me, time to mark RTBC?

Jenechka’s picture

#2 Thank you! Also waiting for the patched version.

tedbow’s picture

Version: 6.x-2.0 » 7.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new632 bytes

I have created a patch against 7.x-2.x-dev.

Here is what I added

// Retrieve the browscap data using HTTP
  $browscap_data_url = variable_get('browscap_data_url', 'http://tempdownloads.browserscap.com/stream.php?PHP_BrowsCapINI');
  $browscap_data = drupal_http_request($browscap_data_url);

I added the variable_get so that you could manually override the url if you wanted to.
http://tempdownloads.browserscap.com/
also lists a full and lite version that you could potentially change the URL to. The simplest way to change variable is probably through drush but this could be done via code also.

I think the main benefit of having a URL override is the potential for the browscap site changing the URL. This is probably what happened to cause this problem in the first place. So with this patch sites could immediately change the URL(without patching) while they waited for the module to be updated.

mondrake’s picture

You can also see the patch in #3 of #1788720: Allow to change the URLs to use for importing useragent information.

It adds 2 variables ( one also for versn checking), plus a change to the admin form to manage them.

studioorange’s picture

@toomanypets: The solution given works like a charm. Thanks.

Cyclodex’s picture

I had issue that adaptivetheme throw an error, regarding Undefined index: ismobiledevice
The URL change helped out and so adaptivetheme is working again fine for me.
Thanks for that!

2ndmile’s picture

#2 worked for me as well.

kenianbei’s picture

Status: Needs review » Reviewed & tested by the community

#2 and #8 both worked for me.

computerwill’s picture

I'm glad that this fix (#2) works. I didn't try the other fixes, but they look interesting, too. In case anyone searches for this later and is stumped as to what was going on here, I figured I would document it as best as I could figure out. It broke because http://tempdownloads.browserscap.com/ changed (added?) the URL for PHP users of their files. The old link (http://tempdownloads.browserscap.com:889/stream.php?BrowsCapINI) now has a warning on their page not to use it with PHP. The new link (http://tempdownloads.browserscap.com/stream.asp?PHP_BrowsCapINI) uses quotes around the values.

The lack of quote was causing the import to choke when it got to line 386, which had the first value with an exclamation mark in the file. It looks like the new link puts quotes around the values. Here are some snippets:

Old link:

[Mozilla/4.0 (compatible; Y!J; for robot study*)]
Parent=Yahoo
Browser=Y!J

[Mozilla/5.0 (compatible; BMC/* (Y!J-AGENT))]
Parent=Yahoo
Browser=Y!J-AGENT/BMC

New link:

[Mozilla/4.0 (compatible; Y!J; for robot study*)]
Parent=Yahoo
Browser="Y!J"

[Mozilla/5.0 (compatible; BMC/* (Y!J-AGENT))]
Parent=Yahoo
Browser="Y!J-AGENT/BMC"

Thanks again, community!

wxman’s picture

#2 and #8 worked for me too.

nateman332’s picture

I can confirm that the patch in #8 work for version 6.x-2.0. (manually changed)

lorenz’s picture

I too confirm that #8 worked for version 6.x-2.0. (manually changed)

mrtoner’s picture

I could not install 7.x-2.0 for the first time until I applied #2.

greggles’s picture

Status: Reviewed & tested by the community » Closed (duplicate)

It feels to me like this is roughly a duplicate of #1788720: Allow to change the URLs to use for importing useragent information which has the same feature and a UI to change the url in the future.