PHP 8.1 is deprecating passing null to internal functions that accept scalar values. Although there is discussion about trying to relax this, the consensus seems to be that developers and frameworks should solve this.
The WP CLI core Utils namespace has a helper function called get_flag_value that accepts a fallback parameter for missing flags that defaults to null:
On lines 226 through 228 of the search-replace command, the return value of that function is passed directly to explode which will result in a deprecation warning if those flags aren't set
Describe how other contributors can replicate this bug
With deprecation warnings enabled, running an valid search-replace command that omits skip-columns, skip-tables or include-columns should show this warning
Describe what you would expect as the correct outcome
No deprecation notice
Let us know what environment you are running this on
Bug Report
Describe the current, buggy behavior
PHP 8.1 is deprecating passing
null
to internal functions that accept scalar values. Although there is discussion about trying to relax this, the consensus seems to be that developers and frameworks should solve this.The WP CLI core
Utils
namespace has a helper function calledget_flag_value
that accepts a fallback parameter for missing flags that defaults tonull
:On lines 226 through 228 of the
search-replace
command, the return value of that function is passed directly toexplode
which will result in a deprecation warning if those flags aren't sethttps://github.com/wp-cli/search-replace-command/blob/7ffc57340e66c2e44e005ee4321f74ed558b6f0f/src/Search_Replace_Command.php#L226-L228
This can be fixed with more LoC with null-checks, or by just passing the empty string as the third argument to that functions on those three lines.
Describe how other contributors can replicate this bug
skip-columns
,skip-tables
orinclude-columns
should show this warningDescribe what you would expect as the correct outcome
Let us know what environment you are running this on
Provide a possible solution
A PR is in progress