From 11ebad6bafb372fe300cf97a25cb9a8f5561ebae Mon Sep 17 00:00:00 2001 From: Sergey Mitroshin Date: Wed, 11 Sep 2024 14:51:55 -0400 Subject: [PATCH] Connection: fix the connected plugins option on multisites (#39355) Recent optimizations of the connected plugin options update/sync exposed an issue in the original implementation, making the "active connected plugins" option always empty on multisites. Here we fix that problem. --- .../connection/changelog/fix-connected-plugins-on-multisites | 4 ++++ projects/packages/connection/src/class-plugin-storage.php | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 projects/packages/connection/changelog/fix-connected-plugins-on-multisites diff --git a/projects/packages/connection/changelog/fix-connected-plugins-on-multisites b/projects/packages/connection/changelog/fix-connected-plugins-on-multisites new file mode 100644 index 0000000000000..a608ebf17009c --- /dev/null +++ b/projects/packages/connection/changelog/fix-connected-plugins-on-multisites @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fix the connected plugins option on multisites. diff --git a/projects/packages/connection/src/class-plugin-storage.php b/projects/packages/connection/src/class-plugin-storage.php index 21d9402bf0e29..c722a7f022a60 100644 --- a/projects/packages/connection/src/class-plugin-storage.php +++ b/projects/packages/connection/src/class-plugin-storage.php @@ -144,7 +144,10 @@ private static function ensure_configured() { } if ( is_multisite() && get_current_blog_id() !== self::$current_blog_id ) { - self::$plugins = (array) get_option( self::ACTIVE_PLUGINS_OPTION_NAME, array() ); + if ( self::$current_blog_id ) { + // If blog ID got changed, pull the list of active plugins for that blog from the database. + self::$plugins = (array) get_option( self::ACTIVE_PLUGINS_OPTION_NAME, array() ); + } self::$current_blog_id = get_current_blog_id(); }