Skip to content

Commit

Permalink
Reverting Stabilization block support
Browse files Browse the repository at this point in the history
  • Loading branch information
karthick-murugan committed Dec 20, 2024
1 parent 27e4bbc commit 12131db
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 118 deletions.
1 change: 0 additions & 1 deletion backport-changelog/6.8/7069.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ https://github.com/WordPress/wordpress-develop/pull/7069
* https://github.com/WordPress/gutenberg/pull/63401
* https://github.com/WordPress/gutenberg/pull/66918
* https://github.com/WordPress/gutenberg/pull/67018
* https://github.com/WordPress/gutenberg/pull/67552
29 changes: 12 additions & 17 deletions lib/compat/wordpress-6.8/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ function gutenberg_stabilize_experimental_block_supports( $args ) {
}

$stabilize_config = function ( $unstable_config, $stable_support_key ) use ( $experimental_support_properties, $common_experimental_properties ) {
if ( ! is_array( $unstable_config ) ) {
return $unstable_config;
}

$stable_config = array();
foreach ( $unstable_config as $key => $value ) {
// Get stable key from support-specific map, common properties map, or keep original.
Expand Down Expand Up @@ -120,19 +116,18 @@ function gutenberg_stabilize_experimental_block_supports( $args ) {
( $key_positions[ $support ] ?? PHP_INT_MAX ) <
( $key_positions[ $stable_support_key ] ?? PHP_INT_MAX );

/*
* To merge the alternative support config effectively, it also needs to be
* stabilized before merging to keep stabilized and experimental flags in
* sync.
*/
$args['supports'][ $stable_support_key ] = $stabilize_config( $args['supports'][ $stable_support_key ], $stable_support_key );
// Prevents reprocessing this support as it was stabilized above.
$done[ $stable_support_key ] = true;

if ( is_array( $stable_config ) && is_array( $args['supports'][ $stable_support_key ] ) ) {
$stable_config = $experimental_first
? array_merge( $stable_config, $args['supports'][ $stable_support_key ] )
: array_merge( $args['supports'][ $stable_support_key ], $stable_config );
if ( is_array( $args['supports'][ $stable_support_key ] ) ) {
/*
* To merge the alternative support config effectively, it also needs to be
* stabilized before merging to keep stabilized and experimental flags in
* sync.
*/
$args['supports'][ $stable_support_key ] = $stabilize_config( $args['supports'][ $stable_support_key ], $stable_support_key );
$stable_config = $experimental_first
? array_merge( $stable_config, $args['supports'][ $stable_support_key ] )
: array_merge( $args['supports'][ $stable_support_key ], $stable_config );
// Prevents reprocessing this support as it was merged above.
$done[ $stable_support_key ] = true;
} else {
$stable_config = $experimental_first
? $args['supports'][ $stable_support_key ]
Expand Down
100 changes: 0 additions & 100 deletions phpunit/block-supports/border-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -730,104 +730,4 @@ public function test_should_stabilize_border_supports_using_order_based_merge()
);
$this->assertSame( $expected, $actual, 'Merged stabilized border block support config does not match when stable keys are first.' );
}

/**
* Tests that boolean border support configurations are handled correctly.
*
* @dataProvider data_boolean_border_supports
*
* @param array $supports The supports configuration to test.
* @param boolean|array $expected_value The expected final border support value.
*/
public function test_should_handle_boolean_border_supports( $supports, $expected_value ) {
$args = array(
'supports' => $supports,
);

$actual = gutenberg_stabilize_experimental_block_supports( $args );

$this->assertSame( $expected_value, $actual['supports']['border'] );
}

/**
* Data provider for boolean border support tests.
*
* @return array Test parameters.
*/
public function data_boolean_border_supports() {
return array(
'experimental true only' => array(
array(
'__experimentalBorder' => true,
),
true,
),
'experimental false only' => array(
array(
'__experimentalBorder' => false,
),
false,
),
'experimental true before stable false' => array(
array(
'__experimentalBorder' => true,
'border' => false,
),
false,
),
'stable true before experimental false' => array(
array(
'border' => true,
'__experimentalBorder' => false,
),
false,
),
'experimental array before stable boolean' => array(
array(
'__experimentalBorder' => array(
'color' => true,
'width' => true,
),
'border' => false,
),
false,
),
'stable array before experimental boolean' => array(
array(
'border' => array(
'color' => true,
'width' => true,
),
'__experimentalBorder' => true,
),
true,
),
'experimental boolean before stable array' => array(
array(
'__experimentalBorder' => true,
'border' => array(
'color' => true,
'width' => true,
),
),
array(
'color' => true,
'width' => true,
),
),
'stable boolean before experimental array' => array(
array(
'border' => false,
'__experimentalBorder' => array(
'color' => true,
'width' => true,
),
),
array(
'color' => true,
'width' => true,
),
),
);
}
}

0 comments on commit 12131db

Please sign in to comment.