Skip to content
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

Deprecation on use of str_replace with php 8.1 #888

Closed
bramley opened this issue Sep 21, 2022 · 3 comments
Closed

Deprecation on use of str_replace with php 8.1 #888

bramley opened this issue Sep 21, 2022 · 3 comments

Comments

@bramley
Copy link
Contributor

bramley commented Sep 21, 2022

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
@michield
Copy link
Member

Yes, I think the easiest is

set $website and $domain to empty strings in connect.php

I'll add it to the tweaks PR.

michield added a commit to bramley/phplist3 that referenced this issue Sep 25, 2022
michield added a commit that referenced this issue Sep 25, 2022
(cherry picked from commit 6510973)
michield added a commit to bramley/phplist3 that referenced this issue Sep 25, 2022
marianaballa pushed a commit that referenced this issue Sep 29, 2022
* Upgrade PHPMailer to version 6.6.3

* #888 - initialise website and domain

* Revert "#888 - initialise website and domain"

This reverts commit 6510973.

Co-authored-by: Michiel Dethmers <michiel@phplist.com>
marianaballa pushed a commit that referenced this issue Sep 29, 2022
* check on var before use

* avoid php notice

* change bugreport link to github issues

* link to the subscribe page area

* find config correctly

* avoid notices

* test on value

* check on var

* avoid error when the DB is not on the same host

* #883 - make defaults more common

* remove outdated JS code

* pass a potential documentation URL on to commandline

* expand on a plugin failing to initialise and add a URL for docs

* fix path to config

* simplify

* use __DIR__

* remove unneeded configs

* deal with 0 values

* #888 - initialise website and domain

(cherry picked from commit 6510973)
@phpListDockerBot
Copy link
Contributor

This issue has been mentioned on phpList Discuss. There might be relevant details there:

https://discuss.phplist.org/t/is-php-8-x-x-supported-by-phplist/8371/16

@michield
Copy link
Member

Fixed in #886

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants