Skip to content

Commit fe9464a

Browse files
authored
Preserve browser runtime versions during post-runtime composition (#1802)
1 parent b236c52 commit fe9464a

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

packages/wordpress-plugin/src/trait-wp-codebox-abilities-browser-blueprint.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ private static function browser_blueprint_with_post_runtime( array $blueprint, a
5656
$post_steps = is_array( $post_runtime_blueprint['steps'] ?? null ) ? $post_runtime_blueprint['steps'] : array();
5757
$merged = array_merge( $blueprint, $post_runtime_blueprint );
5858
$merged['steps'] = array_values( array_merge( $steps, $post_steps ) );
59+
if ( array_key_exists( 'preferredVersions', $blueprint ) ) {
60+
$merged['preferredVersions'] = $blueprint['preferredVersions'];
61+
} else {
62+
unset( $merged['preferredVersions'] );
63+
}
5964

6065
if ( isset( $blueprint['features'] ) && isset( $post_runtime_blueprint['features'] ) && is_array( $blueprint['features'] ) && is_array( $post_runtime_blueprint['features'] ) ) {
6166
$merged['features'] = array_merge( $blueprint['features'], $post_runtime_blueprint['features'] );

scripts/php-browser-post-runtime-blueprint-smoke.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ public static function merge( array $blueprint, array $post_runtime ): array {
1515
}
1616

1717
$runtime_blueprint = array(
18-
'preferredVersions' => array( 'php' => '8.3' ),
18+
'preferredVersions' => array( 'wp' => '7.0', 'php' => '8.4' ),
1919
'features' => array( 'networking' => false ),
2020
'steps' => array(
2121
array( 'step' => 'login' ),
2222
array( 'step' => 'installPlugin', 'pluginData' => array( 'url' => 'runtime.zip' ) ),
2323
),
2424
);
2525
$post_runtime = array(
26-
'features' => array( 'networking' => true ),
27-
'steps' => array( array( 'step' => 'runPHP', 'code' => '<?php import_site();' ) ),
26+
'preferredVersions' => array( 'wp' => 'latest', 'php' => '8.2' ),
27+
'features' => array( 'networking' => true ),
28+
'steps' => array( array( 'step' => 'runPHP', 'code' => '<?php import_site();' ) ),
2829
);
2930

3031
$merged = WP_Codebox_Post_Runtime_Blueprint_Smoke::merge( $runtime_blueprint, $post_runtime );
@@ -34,6 +35,10 @@ public static function merge( array $blueprint, array $post_runtime ): array {
3435
fwrite( STDERR, 'Post-runtime blueprint steps were not appended after runtime materialization.' . PHP_EOL );
3536
exit( 1 );
3637
}
38+
if ( array( 'wp' => '7.0', 'php' => '8.4' ) !== ( $merged['preferredVersions'] ?? null ) ) {
39+
fwrite( STDERR, 'Post-runtime blueprint preferredVersions overwrote the runtime selection.' . PHP_EOL );
40+
exit( 1 );
41+
}
3742
if ( true !== ( $merged['features']['networking'] ?? null ) ) {
3843
fwrite( STDERR, 'Post-runtime blueprint features did not override the base feature.' . PHP_EOL );
3944
exit( 1 );

0 commit comments

Comments
 (0)