From 463534e16d7a6012b438cc6e57356153daf831a4 Mon Sep 17 00:00:00 2001 From: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com> Date: Fri, 18 Sep 2026 16:38:23 +0300 Subject: [PATCH 1/2] Build/Test Tools: Mock the oEmbed discovery request in the spam site embed test. `test_content_from_spam_blog_is_not_available()` embeds a URL from a spam site. `get_oembed_response_data_for_url()` refuses the embed. `WP_oEmbed::discover()` then requests the URL from example.org. Mock that request with `pre_http_request`. Move the test out of the `external-http` group. --- .../tests/multisite/updateBlogStatus.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/multisite/updateBlogStatus.php b/tests/phpunit/tests/multisite/updateBlogStatus.php index 20cd90307fd34..77a62a2b5bb18 100644 --- a/tests/phpunit/tests/multisite/updateBlogStatus.php +++ b/tests/phpunit/tests/multisite/updateBlogStatus.php @@ -46,9 +46,6 @@ public function test_update_blog_status_make_ham_blog_action() { $this->assertSame( 1, $test_action_counter->get_call_count() ); } - /** - * @group external-http - */ public function test_content_from_spam_blog_is_not_available() { $spam_blog_id = self::factory()->blog->create(); switch_to_blog( $spam_blog_id ); @@ -67,6 +64,22 @@ public function test_content_from_spam_blog_is_not_available() { update_blog_status( $spam_blog_id, 'spam', 1 ); + add_filter( + 'pre_http_request', + static function () { + return array( + 'headers' => array(), + 'body' => '', + 'response' => array( + 'code' => 404, + 'message' => 'Not Found', + ), + 'cookies' => array(), + 'filename' => null, + ); + } + ); + $post_id = self::factory()->post->create( array( 'post_content' => "\n $spam_permalink \n", From a4d36a7cf0eb5bf744ff772d8fb9d6692290325e Mon Sep 17 00:00:00 2001 From: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com> Date: Wed, 23 Sep 2026 00:50:25 +0300 Subject: [PATCH 2/2] Build/Test Tools: Switch off oEmbed discovery in the spam site embed test. `test_content_from_spam_blog_is_not_available()` embeds a URL from a spam site. `get_oembed_response_data_for_url()` returns nothing for such a site, so `WP_oEmbed::get_provider()` finds no provider and calls `WP_oEmbed::discover()`, which requests the permalink over HTTP. Replace the `pre_http_request` mock from the previous commit with the `embed_oembed_discover` filter. `get_provider()` then skips `discover()`, and the test makes no request. --- .../tests/multisite/updateBlogStatus.php | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/tests/phpunit/tests/multisite/updateBlogStatus.php b/tests/phpunit/tests/multisite/updateBlogStatus.php index 77a62a2b5bb18..fe28f82bb34cf 100644 --- a/tests/phpunit/tests/multisite/updateBlogStatus.php +++ b/tests/phpunit/tests/multisite/updateBlogStatus.php @@ -64,21 +64,12 @@ public function test_content_from_spam_blog_is_not_available() { update_blog_status( $spam_blog_id, 'spam', 1 ); - add_filter( - 'pre_http_request', - static function () { - return array( - 'headers' => array(), - 'body' => '', - 'response' => array( - 'code' => 404, - 'message' => 'Not Found', - ), - 'cookies' => array(), - 'filename' => null, - ); - } - ); + /* + * The local oEmbed lookup returns nothing for a spam site, so WP_oEmbed::discover() + * would fetch the permalink over HTTP. Switch discovery off to keep the test + * off the network. + */ + add_filter( 'embed_oembed_discover', '__return_false' ); $post_id = self::factory()->post->create( array(