From acad00ecabcf44a6c4e552c4fd518ee708fd131f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Zi=C3=83=C2=B3=C3=85=E2=80=9Akowski?= Date: Fri, 9 Feb 2024 10:52:09 +0000 Subject: [PATCH] Editor: Add wakeup magic method to the block bindings registry See #60282. Follow-up [57373]. Props dmsnell, mukesh27, gziolo. git-svn-id: https://develop.svn.wordpress.org/trunk@57575 602fd350-edb4-49c9-b593-d223f7449a82 --- .../class-wp-block-bindings-registry.php | 19 +++++++++++++++++++ src/wp-includes/class-wp-block.php | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-block-bindings-registry.php b/src/wp-includes/class-wp-block-bindings-registry.php index 65f5f13c36..de6a9d89e4 100644 --- a/src/wp-includes/class-wp-block-bindings-registry.php +++ b/src/wp-includes/class-wp-block-bindings-registry.php @@ -211,6 +211,25 @@ final class WP_Block_Bindings_Registry { return isset( $this->sources[ $source_name ] ); } + /** + * Wakeup magic method. + * + * @since 6.5.0 + */ + public function __wakeup() { + if ( ! $this->sources ) { + return; + } + if ( ! is_array( $this->sources ) ) { + throw new UnexpectedValueException(); + } + foreach ( $this->sources as $value ) { + if ( ! $value instanceof WP_Block_Bindings_Source ) { + throw new UnexpectedValueException(); + } + } + } + /** * Utility method to retrieve the main instance of the class. * diff --git a/src/wp-includes/class-wp-block.php b/src/wp-includes/class-wp-block.php index 14565ab74a..455ea2e138 100644 --- a/src/wp-includes/class-wp-block.php +++ b/src/wp-includes/class-wp-block.php @@ -413,7 +413,7 @@ class WP_Block { // Process the block bindings and get attributes updated with the values from the sources. $computed_attributes = $this->process_block_bindings(); if ( ! empty( $computed_attributes ) ) { - // Merge the computed attributes with the original attributes + // Merge the computed attributes with the original attributes. $this->attributes = array_merge( $this->attributes, $computed_attributes ); }