-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP 8.2 Legacy Error in WebClient.php #42830
Comments
This is a known issue with vendor library 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. |
this has been solved upstream joomla-framework/application#121 |
Please test #42937 . Thanks in advance. |
For 5.x this issue has been fixed with PR #42945 , which will be part of the 5.1.0-beta1 coming up tomorrow. For 4.4 it still needs to be fixed. |
Summary of Issue with WebClient.php
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.
Steps to reproduce the issue
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';
}
Fix the issue
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.
The text was updated successfully, but these errors were encountered: