From cb2b6dbfce56da2cdb279aa2290534afb2659a16 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 21:59:04 +0000 Subject: [PATCH 1/3] Fall back to bundled schemas when the remote schema download fails WP_CLI\Utils\http_request() throws a RuntimeException on transport errors even with halt_on_error set to false, so remote_get() aborted make-pot instead of returning an empty string and using the bundled block-i18n.json / theme-i18n.json fallbacks. Fixes #518. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UWTd5ocijEgHN4xLrNgcUG --- features/makepot.feature | 77 +++++++++++++++++++++++++++++++++++++ src/JsonSchemaExtractor.php | 13 +++++-- 2 files changed, 87 insertions(+), 3 deletions(-) diff --git a/features/makepot.feature b/features/makepot.feature index 24672f6..34acbfb 100644 --- a/features/makepot.feature +++ b/features/makepot.feature @@ -3467,6 +3467,83 @@ Feature: Generate a POT file of a WordPress project msgid "anotherkeyword" """ + Scenario: Falls back to bundled schemas when remote schemas cannot be downloaded + Given an empty foo-plugin directory + And a foo-plugin/foo-plugin.php file: + """ + 'application/json' ]; - $options = [ 'halt_on_error' => false ]; - $response = Utils\http_request( 'GET', $url, null, $headers, $options ); + $headers = [ 'Content-Type' => 'application/json' ]; + $options = [ 'halt_on_error' => false ]; + + try { + $response = Utils\http_request( 'GET', $url, null, $headers, $options ); + } catch ( RuntimeException $exception ) { + WP_CLI::debug( "Failed to download from URL {$url}: {$exception->getMessage()}", 'make-pot' ); + return ''; + } if ( ! $response->success From 0b3561ad11dfb792c869a6838aad0cb03850851f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 22:06:48 +0000 Subject: [PATCH 2/3] Clear NO_PROXY in the offline make-pot scenario cURL ignores the configured proxy for hosts matched by NO_PROXY/no_proxy, so an inherited NO_PROXY=* would let the schema downloads succeed and break the scenario's assertions. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UWTd5ocijEgHN4xLrNgcUG --- features/makepot.feature | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/features/makepot.feature b/features/makepot.feature index 34acbfb..078b145 100644 --- a/features/makepot.feature +++ b/features/makepot.feature @@ -3501,6 +3501,10 @@ Feature: Generate a POT file of a WordPress project And a no-network.php file: """ Date: Mon, 2 Nov 2026 23:45:16 +0000 Subject: [PATCH 3/3] Use wp-cli-tests request mocking in the offline make-pot scenario Replace the unreachable-proxy require file with the built-in "Given that HTTP requests to ... will respond with" step. A mocked response without a header/body separator makes Requests throw, which http_request() turns into a RuntimeException, so the scenario exercises the fixed code path without network access, proxy env vars or retries. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UWTd5ocijEgHN4xLrNgcUG --- features/makepot.feature | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/features/makepot.feature b/features/makepot.feature index 078b145..1abb35d 100644 --- a/features/makepot.feature +++ b/features/makepot.feature @@ -3498,24 +3498,14 @@ Feature: Generate a POT file of a WordPress project } } """ - And a no-network.php file: + # A response without a header/body separator makes Requests throw, which + # WP_CLI\Utils\http_request() turns into a RuntimeException, as on a network error. + And that HTTP requests to https://develop.svn.wordpress.org/trunk/src/wp-includes/ will respond with: """ -