From a6b7c0b85611392c12df99e37798c24680da9202 Mon Sep 17 00:00:00 2001 From: Brandon Kraft Date: Wed, 2 Mar 2022 15:41:42 -0600 Subject: [PATCH] Various: Ensure WP CLI is defined before extending (#23207) * Ensure there is a check before extending a WP CLI class --- projects/packages/search/changelog/update-cli-classes | 4 ++++ projects/packages/search/package.json | 2 +- projects/packages/search/search.php | 2 +- projects/packages/search/src/class-cli.php | 4 ++++ projects/plugins/beta/changelog/update-cli-classes | 4 ++++ projects/plugins/beta/src/class-clicommand.php | 4 ++++ projects/plugins/jetpack/changelog/update-cli-classes | 4 ++++ projects/plugins/jetpack/class.jetpack-cli.php | 4 ++++ 8 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 projects/packages/search/changelog/update-cli-classes create mode 100644 projects/plugins/beta/changelog/update-cli-classes create mode 100644 projects/plugins/jetpack/changelog/update-cli-classes diff --git a/projects/packages/search/changelog/update-cli-classes b/projects/packages/search/changelog/update-cli-classes new file mode 100644 index 0000000000000..33ed63501aeec --- /dev/null +++ b/projects/packages/search/changelog/update-cli-classes @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Ensure that WP CLI is present before extending the class. diff --git a/projects/packages/search/package.json b/projects/packages/search/package.json index 1645e5036219e..55da2203f5d66 100644 --- a/projects/packages/search/package.json +++ b/projects/packages/search/package.json @@ -1,6 +1,6 @@ { "name": "jetpack-search", - "version": "0.10.0", + "version": "0.10.1-alpha", "description": "Package for Jetpack Search products", "main": "main.js", "directories": { diff --git a/projects/packages/search/search.php b/projects/packages/search/search.php index eefaa26acc613..377d953a10859 100644 --- a/projects/packages/search/search.php +++ b/projects/packages/search/search.php @@ -7,7 +7,7 @@ namespace Automattic\Jetpack\Search; -define( 'JETPACK_SEARCH_PKG__VERSION', '0.10.0' ); +define( 'JETPACK_SEARCH_PKG__VERSION', '0.10.1-alpha' ); define( 'JETPACK_SEARCH_PKG__DIR', __DIR__ . '/' ); define( 'JETPACK_SEARCH_PKG__SLUG', 'search' ); diff --git a/projects/packages/search/src/class-cli.php b/projects/packages/search/src/class-cli.php index d4982c44585fb..78fec3d475aa7 100644 --- a/projects/packages/search/src/class-cli.php +++ b/projects/packages/search/src/class-cli.php @@ -11,6 +11,10 @@ use \WP_CLI_Command; use \WP_Error; +if ( ! class_exists( 'WP_CLI_Command' ) ) { + return; +} + /** * Provide functionality by WPCLI. */ diff --git a/projects/plugins/beta/changelog/update-cli-classes b/projects/plugins/beta/changelog/update-cli-classes new file mode 100644 index 0000000000000..33ed63501aeec --- /dev/null +++ b/projects/plugins/beta/changelog/update-cli-classes @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Ensure that WP CLI is present before extending the class. diff --git a/projects/plugins/beta/src/class-clicommand.php b/projects/plugins/beta/src/class-clicommand.php index f636ffb07badf..d0479b2cf7485 100644 --- a/projects/plugins/beta/src/class-clicommand.php +++ b/projects/plugins/beta/src/class-clicommand.php @@ -10,6 +10,10 @@ use WP_CLI; use WP_CLI_Command; +if ( ! class_exists( 'WP_CLI_Command' ) ) { + return; +} + /** * Control your local Jetpack Beta Tester plugin. */ diff --git a/projects/plugins/jetpack/changelog/update-cli-classes b/projects/plugins/jetpack/changelog/update-cli-classes new file mode 100644 index 0000000000000..124ef7927f68a --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-cli-classes @@ -0,0 +1,4 @@ +Significance: patch +Type: compat + +Ensure WP CLI is present before extending the class. diff --git a/projects/plugins/jetpack/class.jetpack-cli.php b/projects/plugins/jetpack/class.jetpack-cli.php index fa16971a5745a..fcf731f5bc4e0 100644 --- a/projects/plugins/jetpack/class.jetpack-cli.php +++ b/projects/plugins/jetpack/class.jetpack-cli.php @@ -16,6 +16,10 @@ use Automattic\Jetpack\Sync\Queue; use Automattic\Jetpack\Sync\Settings; +if ( ! class_exists( 'WP_CLI_Command' ) ) { + return; +} + WP_CLI::add_command( 'jetpack', 'Jetpack_CLI' ); /**