From af9fdb2ca0df86fe329be1f6a989ad1b4f2a52a2 Mon Sep 17 00:00:00 2001 From: david-binda Date: Fri, 30 Aug 2024 15:43:37 +0200 Subject: [PATCH 1/3] Prevent PHP warning produced by the "Howdy" link rewrite --- .../src/features/wpcom-admin-bar/class-wpcom-admin-bar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/class-wpcom-admin-bar.php b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/class-wpcom-admin-bar.php index 76f2d0eb33c9c..30a1bfa87229d 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/class-wpcom-admin-bar.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/class-wpcom-admin-bar.php @@ -55,7 +55,7 @@ class WPCOM_Admin_Bar extends \WP_Admin_Bar { * } */ public function add_node( $args ) { - if ( ! is_array( $args ) || empty( $args['href'] ) ) { + if ( ! is_array( $args ) || empty( $args['href'] ) || ! isset( $args['id'] ) ) { parent::add_node( $args ); return; } From e88acd632b16c126c9b75c4ea745882c24dd06c7 Mon Sep 17 00:00:00 2001 From: david-binda Date: Fri, 30 Aug 2024 16:02:10 +0200 Subject: [PATCH 2/3] Move the `isset` check to let the rest of the code run --- .../src/features/wpcom-admin-bar/class-wpcom-admin-bar.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/class-wpcom-admin-bar.php b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/class-wpcom-admin-bar.php index 30a1bfa87229d..14e1783a67cee 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/class-wpcom-admin-bar.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-bar/class-wpcom-admin-bar.php @@ -55,12 +55,12 @@ class WPCOM_Admin_Bar extends \WP_Admin_Bar { * } */ public function add_node( $args ) { - if ( ! is_array( $args ) || empty( $args['href'] ) || ! isset( $args['id'] ) ) { + if ( ! is_array( $args ) || empty( $args['href'] ) ) { parent::add_node( $args ); return; } - if ( $args['id'] === 'my-account' ) { + if ( isset( $args['id'] ) && $args['id'] === 'my-account' ) { if ( ! is_user_member_of_blog() || get_option( 'wpcom_admin_interface' ) !== 'wp-admin' ) { $args['href'] = 'https://wordpress.com/me'; From c93126c81542cbe1241f18156aa097d07a65917d Mon Sep 17 00:00:00 2001 From: david-binda Date: Fri, 30 Aug 2024 17:11:34 +0200 Subject: [PATCH 3/3] changelogger change enty --- .../jetpack-mu-wpcom/changelog/fix-howdy-link-warning | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/fix-howdy-link-warning diff --git a/projects/packages/jetpack-mu-wpcom/changelog/fix-howdy-link-warning b/projects/packages/jetpack-mu-wpcom/changelog/fix-howdy-link-warning new file mode 100644 index 0000000000000..11a71fce9e9ae --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/fix-howdy-link-warning @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fixed PHP warning for accessing an undefined array key.