Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/compat/wordpress-7.0/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
* @return bool Whether client-side media processing is enabled.
*/
function gutenberg_is_client_side_media_processing_enabled() {
// Disable in php-wasm environments (e.g. WordPress Playground) where
// cross-origin isolation headers conflict with the iframe architecture.
// See https://github.com/WordPress/gutenberg/issues/75941
if ( 'wasm' === PHP_SAPI ) {
return false;
}

/**
* Filters whether client-side media processing is enabled.
*
Expand Down
18 changes: 18 additions & 0 deletions phpunit/media/media-processing-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,24 @@ public function test_client_side_media_processing_enabled_by_default_in_plugin()
$this->assertTrue( gutenberg_is_client_side_media_processing_enabled() );
}

/**
* Tests that client-side media processing is disabled in php-wasm environments.
*
* Note: PHP_SAPI is a runtime constant that cannot be changed in tests.
* This test verifies the check exists in the function source code.
* When PHP_SAPI === 'wasm' (WordPress Playground), the function returns
* false before the filter is ever applied, preventing cross-origin
* isolation headers from conflicting with Playground's iframe architecture.
*
* @covers ::gutenberg_is_client_side_media_processing_enabled
*/
public function test_client_side_media_processing_disabled_in_wasm_environments() {
// Verify the function contains the wasm SAPI check.
$function = new ReflectionFunction( 'gutenberg_is_client_side_media_processing_enabled' );
$source = file_get_contents( $function->getFileName() );
$this->assertStringContainsString( "'wasm' === PHP_SAPI", $source );
}

/**
* Tests that client-side media processing can be disabled via filter.
*
Expand Down
Loading