Needs review
Project:
Counter
Version:
7.x-1.0-beta3
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 Oct 2014 at 09:59 UTC
Updated:
19 Sep 2016 at 03:17 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Philix commentedI suggest :
After line 26
+ After :
Add :
I don't know how to do a patch, sorry
(IE never do like others ... :( )
Comment #2
waluyo.umam commentedI have the same problem in Internet Explorer 11, the red warning shown.
Your code suggestion fixed the problem. I hope this can be included in the next release.
Thanks a lot.
Comment #3
jmuzz commentedThis is Philix's recommendations with some changes to the last part which shouldn't change how it works.
Comment #4
Valera Tumash commented1. Recently in logs I have found few weird sessions from clients without HTTP_USER_AGENT set in $_SERVER. So for this use case I believe it is reasonable to change 4 line from
$user_agent = $_SERVER['HTTP_USER_AGENT'];to
$user_agent = array_key_exists('HTTP_USER_AGENT', $_SERVER) ? $_SERVER['HTTP_USER_AGENT'] : 'Unknown';2. There were few sessions with following HTTP_USER_AGENT:
'Mozilla/4.0 (compatible;HostTracker/2.0;+http://www.host-tracker.com/)'
'Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)'
So I reckon there will always be a case when we got same Undefined offset: 1 in counter_get_browser() notice.
In order to eliminate this I changed the condition to:
I have attached a patch file combined with the previous patch in this issue.
Comment #5
modulusng commentedNotice: Undefined offset: 1 in counter_get_browser()
Notice: Undefined offset: 1 in counter_get_browser() (line 76 of /.../sites/all/modules/counter/counter.lib.inc). This error ocurs only with Internet Explorer 11 but not with older versions. The error is not associated with Chrome and Firefox browsers.
Follow the following steps: Navigate to counter.lib.inc through /.../sites/all/modules/counter/counter.lib.inc and open counter.lib.inc on your editor as to edit the file as follows:
After this:
{
$browser_name = 'Internet Explorer';
$ub = "IE";
}
Add this:
elseif(preg_match('/rv:/i',$user_agent))
{
$browser_name = 'Internet Explorer';
$ub = "rv";
}
After this:
// finally get the correct browser_version number
$known = array('browser_version', $ub, 'other');
$pattern = '#(?' . join('|', $known) .
')+(?*)#';
Add this:
if ($ub == 'rv') $pattern = '#(?' . join('|', $known) . ')+(?*)#';
The above procedure gets the issue resolved. For more info, go to: https://www.myniceitems.com/content/notice-undefined-offset-1-counterget...
Comment #6
firfin commented#5 did not work for me. Getting errors:
Warning: preg_match_all() [function.preg-match-all]: Compilation failed: unrecognized character after (? or )?- at offset 2 in counter_get_browser() (line 65 of ../counter.lib.inc)Trying out #3 now.
Comment #7
plato1123 commentedI notice there are multiple errors in the current release, any chance we can get a new roll out with some of the patches rolled into it? Thanks!!