From fc845c82663896d295fcae162eb73879cd0ac789 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Tue, 22 Oct 2024 10:59:42 -0400 Subject: [PATCH 1/2] Fix unset array key warning in block-bindings.php This has been throwing an error for several weeks on one of my sites Simplest fix is to just bail early if it's unset PHP Warning: Undefined array key "show_in_rest" in /var/www/wp-content/plugins/gutenberg/lib/compat/wordpress-6.7/block-bindings.php on line 70 --- lib/compat/wordpress-6.7/block-bindings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/compat/wordpress-6.7/block-bindings.php b/lib/compat/wordpress-6.7/block-bindings.php index 70ba523ac966e..334396cfb00ee 100644 --- a/lib/compat/wordpress-6.7/block-bindings.php +++ b/lib/compat/wordpress-6.7/block-bindings.php @@ -57,7 +57,7 @@ function gutenberg_update_meta_args_with_label( $args ) { } $schema = array( 'title' => $args['label'] ); - if ( ! is_array( $args['show_in_rest'] ) ) { + if ( ! empty( $args['show_in_rest'] ) && ! is_array( $args['show_in_rest'] ) ) { $args['show_in_rest'] = array( 'schema' => $schema, ); From 74f6ec93578ed03ae791258e74c4d52a0d15a102 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Thu, 31 Oct 2024 11:24:19 -0400 Subject: [PATCH 2/2] Update block-bindings.php --- lib/compat/wordpress-6.7/block-bindings.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/compat/wordpress-6.7/block-bindings.php b/lib/compat/wordpress-6.7/block-bindings.php index 334396cfb00ee..3cecb7fbc0985 100644 --- a/lib/compat/wordpress-6.7/block-bindings.php +++ b/lib/compat/wordpress-6.7/block-bindings.php @@ -56,8 +56,13 @@ function gutenberg_update_meta_args_with_label( $args ) { return $args; } + // Don't update schema if not exposed to REST + if ( ! isset( $args['show_in_rest'] ) ) { + return $args; + } + $schema = array( 'title' => $args['label'] ); - if ( ! empty( $args['show_in_rest'] ) && ! is_array( $args['show_in_rest'] ) ) { + if ( ! is_array( $args['show_in_rest'] ) ) { $args['show_in_rest'] = array( 'schema' => $schema, );