Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am getting this error logged for browscap.module, line 392 or 397.
Checking function browscap_get_browser(), I've noticed that the only return clause (return $info;) is conditional. I suppose this can be the reason that in certain circumstances this function doesn't return an object, as expected in lines 392 and 397.
So, I believe we should:
1. ensure the returned value of browscap_get_browser() function is always an object (so we can be sure $browser in lines after 391 is always an object), or
2. check if $browser is an object or not after browscap_get_browser() call (in line 391)
Comment | File | Size | Author |
---|---|---|---|
#8 | cleanup-and-ensure-returned-value-1025236-8.patch | 3.84 KB | Devin Carlson |
#6 | cleanup-and-ensure-returned-value-1025236-6.patch | 3.88 KB | Devin Carlson |
#1 | browscap-1025236.patch | 1.28 KB | alexweber |
Comments
Comment #1
alexweber CreditAttribution: alexweber commentedThere is already a check in place for this in browscap_exit(), I just added the same logic to browscap_unmonitor() and it fixes the issue, patch is attached.
- Alex
Comment #2
alexweber CreditAttribution: alexweber commentedsorry double post, slow internet here :(
Comment #3
BBCI'm seeing the same behavior in the logs, but the patch in #1 seems to be broken. alexweber, any chance that you can resubmit your patch? I'd be happy to help test.
Comment #4
Devin Carlson CreditAttribution: Devin Carlson commentedI'm not sure how the URL to the patch in #1 got messed up, but the patch can be found at http://drupal.org/files/issues/browscap-1025236.patch.
Comment #5
alexweber CreditAttribution: alexweber commentedI haven't checked on this in a while but there's a decent chance it won't apply clean to the current dev release. Re-roll anyone?
Comment #6
Devin Carlson CreditAttribution: Devin Carlson commentedThe attached patch cleans up
browscap_get_browser()
and ensures that a set of default values are returned when there is no data on the visiting user agent.Comment #7
Devin Carlson CreditAttribution: Devin Carlson commentedCommitted to 7.x-1.x.
Comment #8
Devin Carlson CreditAttribution: Devin Carlson commentedBackport of #6.
Comment #9
Devin Carlson CreditAttribution: Devin Carlson commentedCommitted to 6.x-1.x.