Problem/Motivation
Passing NULL to the $replace parameter of str_replace() and preg_replace() triggers a deprecation in PHP 8.1
Steps to reproduce
$replace: See https://3v4l.org/sikQR
Proposed resolution
Change NULL to an empty string
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3239295-8.patch | 4.99 KB | alexpott |
| #8 | 4-8-interdiff.txt | 982 bytes | alexpott |
| #4 | 3239295-4.patch | 5.95 KB | alexpott |
| #4 | 3-4-interdiff.txt | 982 bytes | alexpott |
Comments
Comment #2
alexpottComment #3
alexpottBroadening this to include all cases where a _replace() function is triggering a deprecation.
Comment #4
alexpottChanged to using str_replace because there's no reason to use the more expensive preg_replace.
I think this one needs it's own issue because calling set() with an empty key doesn't make much sense.
Comment #5
alexpottOpened to #3239298: Fix \Drupal\migrate\Plugin\migrate\destination\EntityConfigBase::updateEntity() so that config translation migrations can be rolled back to address #4.2
Comment #6
daffie commentedLooks good to me.
Comment #7
catchIf
$modules->$dependency->info['version']is NULL, why try to replace anything?Comment #8
alexpottLet's remove that change from this one and re-open #3239287: Fix \Drupal\Core\Extension\ModuleDependencyMessageTrait to not cause deprecations in PHP 8.1 and explore a bit more of what is going on in ModuleDependencyMessageTrait
Leaving at rtbc because only de-scoping something.
Comment #9
alexpottWe're now only dealing with the $replace parameter.
Comment #11
catchCommitted f680e8e and pushed to 9.3.x. Thanks!