From 31a6294b584708ef833dec376a0fc1d53027e713 Mon Sep 17 00:00:00 2001 From: Kopila Shrestha Date: Tue, 18 Mar 2025 12:48:43 +0545 Subject: [PATCH 1/2] Fix fatal error issue in in_array function --- src/Plugin_AutoUpdates_Command.php | 6 +++--- src/Plugin_Command.php | 2 +- src/Theme_AutoUpdates_Command.php | 6 +++--- src/WP_CLI/ParseThemeNameInput.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Plugin_AutoUpdates_Command.php b/src/Plugin_AutoUpdates_Command.php index e334c108..fd8b91bf 100644 --- a/src/Plugin_AutoUpdates_Command.php +++ b/src/Plugin_AutoUpdates_Command.php @@ -85,7 +85,7 @@ public function enable( $args, $assoc_args ) { $plugins = $this->fetcher->get_many( $args ); $auto_updates = get_site_option( static::SITE_OPTION ); - if ( false === $auto_updates ) { + if ( false === $auto_updates || ! is_array( $auto_updates ) ) { $auto_updates = []; } @@ -162,7 +162,7 @@ public function disable( $args, $assoc_args ) { $plugins = $this->fetcher->get_many( $args ); $auto_updates = get_site_option( static::SITE_OPTION ); - if ( false === $auto_updates ) { + if ( false === $auto_updates || ! is_array( $auto_updates ) ) { $auto_updates = []; } @@ -278,7 +278,7 @@ public function status( $args, $assoc_args ) { $plugins = $this->fetcher->get_many( $args ); $auto_updates = get_site_option( static::SITE_OPTION ); - if ( false === $auto_updates ) { + if ( false === $auto_updates || ! is_array( $auto_updates ) ) { $auto_updates = []; } diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 88fbb051..d90cc683 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -751,7 +751,7 @@ protected function get_item_list() { $auto_updates = get_site_option( Plugin_AutoUpdates_Command::SITE_OPTION ); - if ( false === $auto_updates ) { + if ( false === $auto_updates || ! is_array( $auto_updates ) ) { $auto_updates = []; } diff --git a/src/Theme_AutoUpdates_Command.php b/src/Theme_AutoUpdates_Command.php index 204435bc..594d25a7 100644 --- a/src/Theme_AutoUpdates_Command.php +++ b/src/Theme_AutoUpdates_Command.php @@ -85,7 +85,7 @@ public function enable( $args, $assoc_args ) { $themes = $this->fetcher->get_many( $args ); $auto_updates = get_site_option( static::SITE_OPTION ); - if ( false === $auto_updates ) { + if ( false === $auto_updates || ! is_array( $auto_updates ) ) { $auto_updates = []; } @@ -162,7 +162,7 @@ public function disable( $args, $assoc_args ) { $themes = $this->fetcher->get_many( $args ); $auto_updates = get_site_option( static::SITE_OPTION ); - if ( false === $auto_updates ) { + if ( false === $auto_updates || ! is_array( $auto_updates ) ) { $auto_updates = []; } @@ -278,7 +278,7 @@ public function status( $args, $assoc_args ) { $themes = $this->fetcher->get_many( $args ); $auto_updates = get_site_option( static::SITE_OPTION ); - if ( false === $auto_updates ) { + if ( false === $auto_updates || ! is_array( $auto_updates ) ) { $auto_updates = []; } diff --git a/src/WP_CLI/ParseThemeNameInput.php b/src/WP_CLI/ParseThemeNameInput.php index fabb2dad..bfd0ba26 100644 --- a/src/WP_CLI/ParseThemeNameInput.php +++ b/src/WP_CLI/ParseThemeNameInput.php @@ -76,7 +76,7 @@ private function get_all_themes() { $auto_updates = get_site_option( Theme_AutoUpdates_Command::SITE_OPTION ); - if ( false === $auto_updates ) { + if ( false === $auto_updates || ! is_array( $auto_updates ) ) { $auto_updates = []; } From 029340707a223359249544b676de9d08b8ed30cd Mon Sep 17 00:00:00 2001 From: Kopila Shrestha Date: Wed, 19 Mar 2025 10:50:48 +0545 Subject: [PATCH 2/2] Update condition to check only is_array --- src/Plugin_AutoUpdates_Command.php | 6 +++--- src/Plugin_Command.php | 2 +- src/Theme_AutoUpdates_Command.php | 6 +++--- src/WP_CLI/ParseThemeNameInput.php | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Plugin_AutoUpdates_Command.php b/src/Plugin_AutoUpdates_Command.php index fd8b91bf..3a0b4377 100644 --- a/src/Plugin_AutoUpdates_Command.php +++ b/src/Plugin_AutoUpdates_Command.php @@ -85,7 +85,7 @@ public function enable( $args, $assoc_args ) { $plugins = $this->fetcher->get_many( $args ); $auto_updates = get_site_option( static::SITE_OPTION ); - if ( false === $auto_updates || ! is_array( $auto_updates ) ) { + if ( ! is_array( $auto_updates ) ) { $auto_updates = []; } @@ -162,7 +162,7 @@ public function disable( $args, $assoc_args ) { $plugins = $this->fetcher->get_many( $args ); $auto_updates = get_site_option( static::SITE_OPTION ); - if ( false === $auto_updates || ! is_array( $auto_updates ) ) { + if ( ! is_array( $auto_updates ) ) { $auto_updates = []; } @@ -278,7 +278,7 @@ public function status( $args, $assoc_args ) { $plugins = $this->fetcher->get_many( $args ); $auto_updates = get_site_option( static::SITE_OPTION ); - if ( false === $auto_updates || ! is_array( $auto_updates ) ) { + if ( ! is_array( $auto_updates ) ) { $auto_updates = []; } diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index d90cc683..7f3f9f0e 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -751,7 +751,7 @@ protected function get_item_list() { $auto_updates = get_site_option( Plugin_AutoUpdates_Command::SITE_OPTION ); - if ( false === $auto_updates || ! is_array( $auto_updates ) ) { + if ( ! is_array( $auto_updates ) ) { $auto_updates = []; } diff --git a/src/Theme_AutoUpdates_Command.php b/src/Theme_AutoUpdates_Command.php index 594d25a7..f92a67b7 100644 --- a/src/Theme_AutoUpdates_Command.php +++ b/src/Theme_AutoUpdates_Command.php @@ -85,7 +85,7 @@ public function enable( $args, $assoc_args ) { $themes = $this->fetcher->get_many( $args ); $auto_updates = get_site_option( static::SITE_OPTION ); - if ( false === $auto_updates || ! is_array( $auto_updates ) ) { + if ( ! is_array( $auto_updates ) ) { $auto_updates = []; } @@ -162,7 +162,7 @@ public function disable( $args, $assoc_args ) { $themes = $this->fetcher->get_many( $args ); $auto_updates = get_site_option( static::SITE_OPTION ); - if ( false === $auto_updates || ! is_array( $auto_updates ) ) { + if ( ! is_array( $auto_updates ) ) { $auto_updates = []; } @@ -278,7 +278,7 @@ public function status( $args, $assoc_args ) { $themes = $this->fetcher->get_many( $args ); $auto_updates = get_site_option( static::SITE_OPTION ); - if ( false === $auto_updates || ! is_array( $auto_updates ) ) { + if ( ! is_array( $auto_updates ) ) { $auto_updates = []; } diff --git a/src/WP_CLI/ParseThemeNameInput.php b/src/WP_CLI/ParseThemeNameInput.php index bfd0ba26..6fb529d4 100644 --- a/src/WP_CLI/ParseThemeNameInput.php +++ b/src/WP_CLI/ParseThemeNameInput.php @@ -76,7 +76,7 @@ private function get_all_themes() { $auto_updates = get_site_option( Theme_AutoUpdates_Command::SITE_OPTION ); - if ( false === $auto_updates || ! is_array( $auto_updates ) ) { + if ( ! is_array( $auto_updates ) ) { $auto_updates = []; }