How PHP 8.2 deprecated warnings silently broke WP-CLI JSON output on shared hosts
A multi-site WordPress maintenance tool began failing on a Japanese shared host (Xserver) when calls to 'wp plugin list --format=json' returned unparseable output. The root cause was PHP 8.2's deprecation of dynamic properties, which caused older WP-CLI 2.x to emit warning messages that leaked into stdout alongside the JSON data. Diagnostic checks for SSH connectivity and WP-CLI version passed cleanly, masking the problem until the structured JSON parsing stage. The issue stemmed from the host's php.ini routing deprecation warnings to stdout rather than stderr, causing json_decode() to fail on the mixed output. Developers addressed this with a multi-layer defence, starting with the WP_CLI_PHP_ARGS environment variable to suppress deprecated and notice-level warnings at the PHP invocation level without hiding genuine errors.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in