E_DEPRECATED: str_replace() in plugin_functions.php
3 posts by 2 authors in: Forums > CMS Builder
Last Post: August 30, 2022 (RSS)
By Deborah - August 30, 2022
Hi, Interactive Tools.
It appears a PHP 8 code update might be needed in /lib/plugin_functions.php for my v3.56 installations. The error log records the following error every time cron.php runs (set to every 5 min).
ERROR
#23041 - E_DEPRECATED: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
/home/webpvw4vps1/public_html/_cmsb356/lib/plugin_functions.php (line 458)
BACKTRACE
#0 _errorlog_logErrorRecord() called at [/home/webpvw4vps1/public_html/_cmsb356/lib/errorlog_functions.php:64]
#1 _errorlog_catchRuntimeErrors() called
#2 str_replace() called at [/home/webpvw4vps1/public_html/_cmsb356/lib/plugin_functions.php:458]
#3 getPluginPathAndUrl() called at [/home/webpvw4vps1/public_html/_cmsb356/lib/plugin_functions.php:566]
#4 pluginAction_addHandlerAndLink() called at [/home/webpvw4vps1/public_html/_cmsb356/plugins/autoBackup_1-04/autoBackup.php:31]
#5 include_once() called at [/home/webpvw4vps1/public_html/_cmsb356/lib/plugin_functions.php:22]
#6 loadPlugins() called at [/home/webpvw4vps1/public_html/_cmsb356/lib/init.php:143]
#7 require_once() called at [/home/webpvw4vps1/public_html/_cmsb356/cron.php:19]
RAW LOG DATA
Array
(
[logType] => runtime
[errno] => 8192
[errstr] => str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
[errfile] => /home/webpvw4vps1/public_html/_cmsb356/lib/plugin_functions.php
[errline] => 458
[errcontext] => *** in symbol table field above ***
)
--------------------------------------
Probably just an annoying error, without consequences, but it does fill up the error log. Hoping there's a simple code change I can make.
Thanks for having a look!
~ Deborah
By daniel - August 30, 2022
Hi Deborah,
Thanks for the report! Yes, this should be a relatively straightforward fix. Can you try changing this line in /cmsb/lib/plugin_functions.php (at or near line 458):
$pluginUrl = str_replace(' ', '%20', @$_SERVER['SCRIPT_NAME']); // url encoded spaces
To this:
$pluginUrl = str_replace(' ', '%20', $_SERVER['SCRIPT_NAME']??''); // url encoded spaces
Let me know if that clears up the errors!
Thanks,
Technical Lead
interactivetools.com
By Deborah - August 30, 2022
Hi, Daniel. Your suggested worked!
While reviewing the CMSB error log I noticed an occasional similar error being recorded, so I modified the following:
/lib/database_functions.php - line 450:
$hostname = preg_replace('/[^\w\d\-\.]/', '', @$_SERVER['HTTP_HOST']);
changed to:
$hostname = preg_replace('/[^\w\d\-\.]/', '', $_SERVER['HTTP_HOST']??'');
I've not seen these errors logged after the change.
Thank you once again for your help!
~ Deborah