-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Occasionally I find a constant becomes defined twice in wp-config.php - due to a plugin adding something that already exists.
In that case the already defined error is thrown twice, and one of them is in stdout making it hard to ignore/ditch.
E.g. if DISALLOW_FILE_EDIT is defined twice:
$ wp option get siteurl
=> `PHP Notice: Constant DISALLOW_FILE_EDIT already defined in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1150) : eval()'d code on line 81
Notice: Constant DISALLOW_FILE_EDIT already defined in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1150) : eval()'d code on line 81
http://test.com`
$ wp option get siteurl --quiet
=> (as above)
$ wp option get siteurl --quiet 2>/dev/null
=> Notice: Constant DISALLOW_FILE_EDIT already defined in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1150) : eval()'d code on line 81 http://test.com
To guarantee only the desired output is returned we are currently grepp'ing out blank lines and lines starting 'Notice' (suits our current use, but not at all robust). Especially as we are relying on json output.
This "feels" like a bug in WP CLI - I wonder if one error comes from PHP itself and one from WP CLI? Is perhaps stderr from PHP being redirected to WP CLI's stdout? I feel out of my depth to dig into the cause, and tight on time to flounder around, but would be more than happy to provide any more (guided) help and testing.