Joomla Version 6.1.2
PHP Version 8.4.x
Problem Description
The default Cassiopeia template (templates/cassiopeia/offline.php) calls str_replace() on the value returned by:
$app->get('offline_message')
If no offline message has been configured, this value is null.
With PHP 8.4 this results in the following deprecated warning:
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
The affected code is:
get('display_offline_message', 1) == 1 && str_replace(' ', '', $app->get('offline_message')) != '') : ?>Steps to reproduce
Install Joomla 6.1.2.
Use PHP 8.4.
Enable Offline Mode.
Leave the "Offline Message" field empty.
Open the offline page.
6.1
No deprecated warnings should be generated.
PHP outputs:
Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
No response
Suggested fix:
Cast the value to a string before passing it to str_replace():
str_replace(' ', '', (string) $app->get('offline_message'))
or, even better, use trim() since the code is only checking whether the message is empty:
trim((string) $app->get('offline_message')) !== ''
This avoids the PHP 8.4 deprecation warning and more clearly expresses the intended logic.
| Labels |
Added:
bug
|
||
| Labels |
Added:
No Code Attached Yet
|
||
Does it also happen with Joomla 5.4.7?