phplist3
phplist3 copied to clipboard
Deprecation on use of str_replace with php 8.1
Using php 8.1 I get deprecations for use of null parameter to str_replace()
PHP Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/defaultconfig.php on line 765
PHP Stack trace:
PHP 1. {main}() /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/index.php:0
PHP 2. require_once() /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/index.php:114
PHP 3. getConfig($item = 'organisation_name') /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/connect.php:14
PHP 4. str_replace($search = '[WEBSITE]', $replace = NULL, $subject = 'Smith & Jones') /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/defaultconfig.php:765
This seems to highlight a problem with the order of use of the website and domain configuration settings. In connect.php line 15 the variables $website and $domain are set by this code
$organisation_name = getConfig('organisation_name');
$domain = getConfig('domain');
$website = getConfig('website');
But the function getConfig() uses those variables and expects them to be already set., line 765 in defaultconfig.php
$value = str_replace('[WEBSITE]', $website, $value);
$value = str_replace('[DOMAIN]', $domain, $value);
Two possible solutions
- make a special case for $item being 'website' or 'domain' in getConfig() and re-order the lines in connect.php so that domain and website are dealt with first
- set $website and $domain to empty strings in connect.php