After upgrading to Joomla 5.X from previous versions, and updating to PHP 8.2.X, there is an error in the error log for WebClient.php. The line numbers vary.
stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /home/name/public_html/libraries/vendor/joomla/application/src/Web/WebClient.php on line XXX.
View PHP Error log for Joomla site with PHP 8.2.X.
Locate the error:
/home/name/public_html/libraries/vendor/joomla/application/src/Web/WebClient.php on line XXX.
Open the file /home/name/public_html/libraries/vendor/joomla/application/src/Web/WebClient.php
Find this code:
// Attempt to detect the browser type. Obviously we are only worried about major browsers.
if ((\stripos($userAgent, 'MSIE') !== false) && (\stripos($userAgent, 'Opera') === false)) {
$this->browser = self::IE;
$patternBrowser = 'MSIE';
} elseif (\stripos($userAgent, 'Trident') !== false) {
$this->browser = self::IE;
$patternBrowser = ' rv';
} elseif (\stripos($userAgent, 'Edge') !== false) {
$this->browser = self::EDGE;
$patternBrowser = 'Edge';
} elseif (\stripos($userAgent, 'Edg') !== false) {
$this->browser = self::EDG;
$patternBrowser = 'Edg';
} elseif ((\stripos($userAgent, 'Firefox') !== false) && (\stripos($userAgent, 'like Firefox') === false)) {
$this->browser = self::FIREFOX;
$patternBrowser = 'Firefox';
} elseif (\stripos($userAgent, 'OPR') !== false) {
$this->browser = self::OPERA;
$patternBrowser = 'OPR';
} elseif (\stripos($userAgent, 'Chrome') !== false) {
$this->browser = self::CHROME;
$patternBrowser = 'Chrome';
} elseif (\stripos($userAgent, 'Safari') !== false) {
$this->browser = self::SAFARI;
$patternBrowser = 'Safari';
} elseif (\stripos($userAgent, 'Opera') !== false) {
$this->browser = self::OPERA;
$patternBrowser = 'Opera';
}
Replace it with this code:
// Attempt to detect the browser type. Obviously we are only worried about major browsers.
if ($userAgent !== null) {
if ((stripos($userAgent, 'MSIE') !== false) && (stripos($userAgent, 'Opera') === false)) {
$this->browser = self::IE;
$patternBrowser = 'MSIE';
} elseif (stripos($userAgent, 'Trident') !== false) {
$this->browser = self::IE;
$patternBrowser = ' rv';
} elseif (stripos($userAgent, 'Edge') !== false) {
$this->browser = self::EDGE;
$patternBrowser = 'Edge';
} elseif (stripos($userAgent, 'Edg') !== false) {
$this->browser = self::EDG;
$patternBrowser = 'Edg';
} elseif ((stripos($userAgent, 'Firefox') !== false) && (stripos($userAgent, 'like Firefox') === false)) {
$this->browser = self::FIREFOX;
$patternBrowser = 'Firefox';
} elseif (stripos($userAgent, 'OPR') !== false) {
$this->browser = self::OPERA;
$patternBrowser = 'OPR';
} elseif (stripos($userAgent, 'Chrome') !== false) {
$this->browser = self::CHROME;
$patternBrowser = 'Chrome';
} elseif (stripos($userAgent, 'Safari') !== false) {
$this->browser = self::SAFARI;
$patternBrowser = 'Safari';
} elseif (stripos($userAgent, 'Opera') !== false) {
$this->browser = self::OPERA;
$patternBrowser = 'Opera';
}
}
This fixes the error.
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-02-22 11:45:57 |
Closed_By | ⇒ | alikon |
this has been solved upstream joomla-framework/application#121
This is a known issue with vendor library
joomla/application
version 3.0.0.As far as I understand it has been fixed by @alikon already in version 3.0.1. See joomla-framework/application@3.0.0...3.0.1
But I don't know why 3.0.1 is not used yet. It has been released on 2024-01-18.