PHP notices
Posted: Mon Feb 22, 2016 2:29 am
We noticed that there is an error in de code of UcwebU3Handler.php on line 86 which causes Notices.
It's this piece of code which assumes there is an key "1" in the array, while its not:
I have made a temporary fix by changing it into:
En example useragent which triggered this notice this was:
Then there is a notice in UcwebU3.php on line 58. Again an assumption is made that an array key exists while it does not:
I fixed it by using this code:
The user agent which triggered this notice was:
In my opinion the code should be errors free, no matter the severity of the error (e.g. notice or warning). I hope you can fix these problens.
It's this piece of code which assumes there is an key "1" in the array, while its not:
Code: Select all
$significant_version = explode('.', $version);
if ($significant_version[0] !== null) {
if ($significant_version[1] === 0) {
$deviceID = 'generic_ms_phone_os'.$significant_version[0].'_subuaucweb';
}
else {
$deviceID = 'generic_ms_phone_os'.$significant_version[0].'_'.$significant_version[1].'_subuaucweb';
}
if (in_array($deviceID, self::$constantIDs)) {
return $deviceID;
}
}
Code: Select all
if ( !array_key_exists(1, $significant_version )|| $significant_version[1] === 0) {
$deviceID = 'generic_ms_phone_os'.$significant_version[0].'_subuaucweb';
}
else {
$deviceID = 'generic_ms_phone_os'.$significant_version[0].'_'.$significant_version[1].'_subuaucweb';
}
Code: Select all
Mozilla/5.0 (Linux; U; Android 8.0; en-US; Windows Phone 8 Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/10.8.0.718 U3/0.8.0 Mobile Safari/534.30
Code: Select all
//iPhone U3K
else if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'iPhone;')) {
if (preg_match('/iPhone OS (\d+)(?:_(\d+))?(?:_\d+)* like/', $userAgent, $matches)) {
$version = $matches[1].'.'.$matches[2];
$prefix = "$version U3iPhone $ucb_version".WURFL_Constants::RIS_DELIMITER;
return $prefix.$userAgent;
}
}
Code: Select all
$version = (array_key_exists( 1, $matches) ? $matches[1] : '').'.'.(array_key_exists( 2, $matches) ? $matches[2] : '');
Code: Select all
Mozilla/5.0 (iPhone; CPU iPhone OS 84 like Mac OS X; zh-CN) AppleWebKit/537.51.1 (KHTML like Gecko) Mobile/12H143 UCBrowser/10.3.0.547 Mobile