You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
make-pot fails without network: remote_get() doesn't catch the exception http_request() throws, so the bundled schemas are never used #518
wp i18n make-pot fetches block-i18n.json and theme-i18n.json from wordpress-develop's trunk, and is meant to fall back to the copies it bundles (JsonSchemaExtractor::THEME_JSON_FALLBACK and BLOCK_JSON_FALLBACK) when the fetch fails. remote_get() passes halt_on_error => false, and its docblock says it "Returns an empty string in case of error".
But on a transport error, WP_CLI\Utils\http_request() with halt_on_error false doesn't return a failed response. It throws a RuntimeException (wp-cli/wp-cli php/utils.php, both throw new RuntimeException( $error_msg, 0, $exception ) paths). remote_get() doesn't catch it, so make-pot aborts and the fallback is never used.
Steps to reproduce
Use a plugin or theme with a block.json (or a theme.json).
Run WP-CLI with the i18n command and no network, for example in a container started with docker run --network none. PHP without a CA bundle (php-wasm) hits the same path.
Run wp i18n make-pot . languages/x.pot.
Expected
A debug message ("Failed to download from URL …"), extraction with the bundled schema, and the POT written.
Actual
make-pot stops with Failed to get url 'https://develop.svn.wordpress.org/trunk/src/wp-includes/block-i18n.json': … and writes nothing.
Seen with 2.7.0, and the code is the same on main.
Suggested fix
Catch RuntimeException around the http_request() call in remote_get() and return '', which already selects the fallback. A Behat scenario could run make-pot with the proxy set to an unreachable address.
For context: we run make-pot under php-wasm and in containers without network. Until this is fixed, we seed the extractor's schema cache with the bundled copies before make-pot runs (a --require file hooked on before_invoke:i18n make-pot).
Activity
Fall back to bundled schemas when the remote schema download fails
Fall back to bundled schemas when the remote schema download fails (w…