File: core/Common.php
Line #: On or about 942
Function: getCampaignParameters()
Line: array_walk_recursive($return, 'trim');
This should do nothing. 'trim' does not meet the callback requirements of array_walk_recursive.
callback expects 2 parameters, my_callback(&$value, $index). trim takes trim($str, $charset)
a) $index will mess up charset
b) if you want to change $value it needs to be referenced, trim returns the value
Suggested resolutions:
-
remove offending line, it has never worked and no one noticed.
-
Move the trim function to the loop
From This:
foreach ($return as &$list) {
if (strpos($list, ',') !== false) {
$list = explode(',', $list);
} else {
$list = array($list);
}
}
To This:
foreach ($return as &$list) {
if (strpos($list, ',') !== false) {
$list = array_map('trim', explode(',', $list));
} else {
$list = array(trim($list));
}
}
-
Create wrapper function for trim:
array_walk_recursive($return, create_function('&$v, $k', '$v = trim($v);');
Backstory:
I am currently playing with getting piwik running on hhvm. I am was getting a warning from the offending line. That is how and why I cam across this.
Code History:
The code was added with regard to ticket #855
with a commit message of:
Fixes #855 Now detecting google style campaign parameters (utm_campaign, utm_term)
git-svn-id: http://dev.piwik.org/svn/trunk@4389 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Committed By: mattpiwik
On: 2011-04-10 23:36:30
File: core/Common.php
Line #: On or about 942
Function: getCampaignParameters()
Line: array_walk_recursive($return, 'trim');
This should do nothing. 'trim' does not meet the callback requirements of array_walk_recursive.
callback expects 2 parameters, my_callback(&$value, $index). trim takes trim($str, $charset)
a) $index will mess up charset
b) if you want to change $value it needs to be referenced, trim returns the value
Suggested resolutions:
remove offending line, it has never worked and no one noticed.
Move the trim function to the loop
From This:
foreach ($return as &$list) {
if (strpos($list, ',') !== false) {
$list = explode(',', $list);
} else {
$list = array($list);
}
}
To This:
foreach ($return as &$list) {
if (strpos($list, ',') !== false) {
$list = array_map('trim', explode(',', $list));
} else {
$list = array(trim($list));
}
}
Create wrapper function for trim:
array_walk_recursive($return, create_function('&$v, $k', '$v = trim($v);');
Backstory:
I am currently playing with getting piwik running on hhvm. I am was getting a warning from the offending line. That is how and why I cam across this.
Code History:
The code was added with regard to ticket #855
with a commit message of:
Fixes #855 Now detecting google style campaign parameters (utm_campaign, utm_term)
git-svn-id: http://dev.piwik.org/svn/trunk@4389 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Committed By: mattpiwik
On: 2011-04-10 23:36:30