From 0fefa8c24ba920a0adc025460e3c44e32ce525f2 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 12 Jan 2022 19:35:25 -0600 Subject: [PATCH 01/28] Adapt branch alias to change from master to main --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f0482f6..8d9e79f 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ }, "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-main": "2.x-dev" }, "commands": [ "doctor check", From 646a8c1378a372025f6fa90182d57929a017db10 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 12 Jan 2022 21:00:20 -0600 Subject: [PATCH 02/28] Update package structure --- command.php | 27 ---------------- composer.json | 13 +++++--- doctor-command.php | 13 ++++++++ doctor.yml | 32 +++++++++---------- inc/checks/class-check.php => src/Check.php | 2 +- .../Check/AutoloadOptionsSize.php | 5 +-- .../Check/CacheFlush.php | 6 ++-- .../Check/ConstantDefinition.php | 5 +-- .../Check/CoreUpdate.php | 5 +-- .../Check/CoreVerifyChecksums.php | 5 +-- .../class-cron.php => src/Check/Cron.php | 3 +- .../Check/CronCount.php | 4 +-- .../Check/CronDuplicates.php | 4 +-- .../class-file.php => src/Check/File.php | 4 ++- .../Check/FileContents.php | 4 +-- .../Check/FileType.php | 4 +-- .../Check/LanguageUpdate.php | 5 +-- .../Check/OptionValue.php | 5 +-- .../Check/PHPInUpload.php | 7 ++-- .../class-plugin.php => src/Check/Plugin.php | 3 +- .../Check/PluginActiveCount.php | 4 +-- .../Check/PluginDeactivated.php | 4 +-- .../Check/PluginStatus.php | 4 +-- .../Check/PluginUpdate.php | 4 +-- .../Check/ThemeUpdate.php | 5 +-- inc/class-checks.php => src/Checks.php | 12 +++---- inc/class-command.php => src/Command.php | 4 +-- inc/class-exception.php => src/Exception.php | 2 +- wp-cli.yml | 2 +- 29 files changed, 99 insertions(+), 98 deletions(-) delete mode 100644 command.php create mode 100644 doctor-command.php rename inc/checks/class-check.php => src/Check.php (97%) rename inc/checks/class-autoload-options-size.php => src/Check/AutoloadOptionsSize.php (92%) rename inc/checks/class-cache-flush.php => src/Check/CacheFlush.php (92%) rename inc/checks/class-constant-definition.php => src/Check/ConstantDefinition.php (97%) rename inc/checks/class-core-update.php => src/Check/CoreUpdate.php (91%) rename inc/checks/class-core-verify-checksums.php => src/Check/CoreVerifyChecksums.php (87%) rename inc/checks/class-cron.php => src/Check/Cron.php (88%) rename inc/checks/class-cron-count.php => src/Check/CronCount.php (90%) rename inc/checks/class-cron-duplicates.php => src/Check/CronDuplicates.php (92%) rename inc/checks/class-file.php => src/Check/File.php (94%) rename inc/checks/class-file-contents.php => src/Check/FileContents.php (96%) rename inc/checks/class-file-type.php => src/Check/FileType.php (94%) rename inc/checks/class-language-update.php => src/Check/LanguageUpdate.php (92%) rename inc/checks/class-option-value.php => src/Check/OptionValue.php (95%) rename inc/checks/class-php-in-upload.php => src/Check/PHPInUpload.php (91%) rename inc/checks/class-plugin.php => src/Check/Plugin.php (88%) rename inc/checks/class-plugin-active-count.php => src/Check/PluginActiveCount.php (90%) rename inc/checks/class-plugin-deactivated.php => src/Check/PluginDeactivated.php (91%) rename inc/checks/class-plugin-status.php => src/Check/PluginStatus.php (95%) rename inc/checks/class-plugin-update.php => src/Check/PluginUpdate.php (90%) rename inc/checks/class-theme-update.php => src/Check/ThemeUpdate.php (90%) rename inc/class-checks.php => src/Checks.php (90%) rename inc/class-command.php => src/Command.php (99%) rename inc/class-exception.php => src/Exception.php (61%) diff --git a/command.php b/command.php deleted file mode 100644 index 8d10b60..0000000 --- a/command.php +++ /dev/null @@ -1,27 +0,0 @@ - Date: Wed, 12 Jan 2022 21:18:32 -0600 Subject: [PATCH 03/28] Adapt tests --- behat.yml | 7 +++++++ bin/readme/installing-body.md | 14 +++---------- composer.json | 2 +- features/check-autoload-options-size.feature | 2 +- features/check-constant-definition.feature | 6 +++--- features/check-file-contents.feature | 6 +++--- features/check-file-type.feature | 4 ++-- features/check-option-value.feature | 12 +++++------ features/check-plugin-active-count.feature | 2 +- features/check-plugin-deactivated.feature | 2 +- features/check-plugin-status.feature | 10 ++++----- features/config.feature | 22 ++++++++++---------- 12 files changed, 44 insertions(+), 45 deletions(-) create mode 100644 behat.yml diff --git a/behat.yml b/behat.yml new file mode 100644 index 0000000..d6ee862 --- /dev/null +++ b/behat.yml @@ -0,0 +1,7 @@ +default: + suites: + default: + contexts: + - WP_CLI\Tests\Context\FeatureContext + paths: + - features diff --git a/bin/readme/installing-body.md b/bin/readme/installing-body.md index 6da5f40..c889f20 100644 --- a/bin/readme/installing-body.md +++ b/bin/readme/installing-body.md @@ -1,13 +1,5 @@ -`wp doctor` is available to [runcommand gold and silver subscribers](https://runcommand.io/pricing/). +You can install the `wp-cli/doctor-command` package via the following command: -Once you've signed up, you can [download the latest version](https://runcommand.memberful.com/account/downloads) from your account dashboard. Then, install `wp doctor` with: - -``` -$ wp package install doctor.zip -``` - -If you have a Github developer seat, you can also run: - -``` -$ wp package install git@github.com:runcommand/doctor.git +```bash +wp package install wp-cli/doctor-command ``` diff --git a/composer.json b/composer.json index 50bda6b..9d8614b 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "wp-cli/wp-cli": "^2.1" }, "require-dev": { - "wp-cli/wp-cli-tests": "^2.1" + "wp-cli/wp-cli-tests": "^3.1.4" }, "config": { "process-timeout": 7200, diff --git a/features/check-autoload-options-size.feature b/features/check-autoload-options-size.feature index 8275760..07b98f8 100644 --- a/features/check-autoload-options-size.feature +++ b/features/check-autoload-options-size.feature @@ -50,7 +50,7 @@ Feature: Check the size of autoloaded options And a custom.yml file: """ autoload-options-size: - class: runcommand\Doctor\Checks\Autoload_Options_Size + class: WP_CLI\Doctor\Check\AutoloadOptionsSize options: threshold_kb: 800 """ diff --git a/features/check-constant-definition.feature b/features/check-constant-definition.feature index 217e4d1..a6f7959 100644 --- a/features/check-constant-definition.feature +++ b/features/check-constant-definition.feature @@ -71,7 +71,7 @@ Feature: Check the values of defined constants And a config.yml file: """ constant-db-host-defined: - class: runcommand\Doctor\Checks\Constant_Definition + class: WP_CLI\Doctor\Check\ConstantDefinition options: constant: DB_HOST defined: true @@ -87,7 +87,7 @@ Feature: Check the values of defined constants And a config.yml file: """ constant-foobar-true: - class: runcommand\Doctor\Checks\Constant_Definition + class: WP_CLI\Doctor\Check\ConstantDefinition options: constant: FOOBAR value: true @@ -108,7 +108,7 @@ Feature: Check the values of defined constants And a config.yml file: """ constant-foobar-true: - class: runcommand\Doctor\Checks\Constant_Definition + class: WP_CLI\Doctor\Check\ConstantDefinition options: constant: FOOBAR value: true diff --git a/features/check-file-contents.feature b/features/check-file-contents.feature index 96582fe..8263b97 100644 --- a/features/check-file-contents.feature +++ b/features/check-file-contents.feature @@ -37,7 +37,7 @@ Feature: Check files in a WordPress install And a config.yml file: """ file-sessions: - check: File_Contents + check: FileContents options: regex: .*(session_start|\$_SESSION).* only_wp_content: true @@ -74,7 +74,7 @@ Feature: Check files in a WordPress install And a config.yml file: """ file-server-name-wp-config: - check: File_Contents + check: FileContents options: regex: define\(.+WP_(HOME|SITEURL).+\$_SERVER.+SERVER_NAME path: wp-config.php @@ -122,7 +122,7 @@ Feature: Check files in a WordPress install And a config.yml file: """ file-content-exist: - check: File_Contents + check: FileContents options: regex: .*wp-doctor-exists-test.* only_wp_content: true diff --git a/features/check-file-type.feature b/features/check-file-type.feature index 009801b..78bbf27 100644 --- a/features/check-file-type.feature +++ b/features/check-file-type.feature @@ -5,7 +5,7 @@ Feature: Check the type of file And a config.yml file: """ file-object-cache-symlink: - check: File_Type + check: FileType options: path: wp-content/object-cache.php symlink: false @@ -38,7 +38,7 @@ Feature: Check the type of file And a config.yml file: """ file-object-cache-symlink: - check: File_Type + check: FileType options: path: wp-content/object-cache.php symlink: true diff --git a/features/check-option-value.feature b/features/check-option-value.feature index af42c5a..35ad3c3 100644 --- a/features/check-option-value.feature +++ b/features/check-option-value.feature @@ -13,7 +13,7 @@ Feature: Check the value of a given option And a blog-private.yml file: """ option-blog-private: - check: Option_Value + check: OptionValue options: option: blog_public value: 0 @@ -21,7 +21,7 @@ Feature: Check the value of a given option And a blog-public.yml file: """ option-blog-public: - check: Option_Value + check: OptionValue options: option: blog_public value: 1 @@ -74,7 +74,7 @@ Feature: Check the value of a given option And a config.yml file: """ option-admin-email: - check: Option_Value + check: OptionValue options: option: admin_email value: foo@example.org @@ -106,7 +106,7 @@ Feature: Check the value of a given option And a config.yml file: """ option-admin-email: - check: Option_Value + check: OptionValue options: option: admin_email value_is_not: foo@example.org @@ -139,7 +139,7 @@ Feature: Check the value of a given option And a config.yml file: """ option-users-can-register: - check: Option_Value + check: OptionValue options: option: users_can_register value: 0 @@ -172,7 +172,7 @@ Feature: Check the value of a given option And a config.yml file: """ option-users-can-register: - check: Option_Value + check: OptionValue options: option: users_can_register value: 0 diff --git a/features/check-plugin-active-count.feature b/features/check-plugin-active-count.feature index 3047b1b..48c9f4b 100644 --- a/features/check-plugin-active-count.feature +++ b/features/check-plugin-active-count.feature @@ -22,7 +22,7 @@ Feature: Check whether a high number of plugins are activated And a config.yml file: """ plugin-active-count: - class: runcommand\Doctor\Checks\Plugin_Active_Count + class: WP_CLI\Doctor\Check\PluginActiveCount options: threshold_count: 3 """ diff --git a/features/check-plugin-deactivated.feature b/features/check-plugin-deactivated.feature index b8dee11..3df6d38 100644 --- a/features/check-plugin-deactivated.feature +++ b/features/check-plugin-deactivated.feature @@ -32,7 +32,7 @@ Feature: Check whether a high percentage of plugins are deactivated And a custom.yml file: """ plugin-deactivated: - class: runcommand\Doctor\Checks\Plugin_Deactivated + class: WP_CLI\Doctor\Check\PluginDeactivated options: threshold_percentage: 60 """ diff --git a/features/check-plugin-status.feature b/features/check-plugin-status.feature index 0fa05a2..a9f7ce5 100644 --- a/features/check-plugin-status.feature +++ b/features/check-plugin-status.feature @@ -5,7 +5,7 @@ Feature: Check the status of a plugin And a config.yml file: """ plugin-akismet-active: - class: runcommand\Doctor\Checks\Plugin_Status + class: WP_CLI\Doctor\Check\PluginStatus options: name: akismet status: active @@ -21,12 +21,12 @@ Feature: Check the status of a plugin And a config.yml file: """ plugin-akismet-active: - class: runcommand\Doctor\Checks\Plugin_Status + class: WP_CLI\Doctor\Check\PluginStatus options: name: akismet status: active plugin-hello-uninstalled: - class: runcommand\Doctor\Checks\Plugin_Status + class: WP_CLI\Doctor\Check\PluginStatus options: name: hello status: uninstalled @@ -71,7 +71,7 @@ Feature: Check the status of a plugin And a config.yml file: """ plugin-akismet-active-network: - class: runcommand\Doctor\Checks\Plugin_Status + class: WP_CLI\Doctor\Check\PluginStatus options: name: akismet status: active-network @@ -80,5 +80,5 @@ Feature: Check the status of a plugin When I try `wp doctor check plugin-akismet-active-network --config=config.yml` Then STDERR should be: """ - Error: Invalid plugin_status. Should be one of: uninstalled, installed, active. + Error: Invalid PluginStatus. Should be one of: uninstalled, installed, active. """ diff --git a/features/config.feature b/features/config.feature index ba3e533..43c33d5 100644 --- a/features/config.feature +++ b/features/config.feature @@ -14,13 +14,13 @@ Feature: Configure the Doctor And a config.yml file: """ undefined-class: - class: Class_Undefined + class: ClassUndefined """ When I try `wp doctor check --all --config=config.yml` Then STDERR should be: """ - Error: Class 'Class_Undefined' for check 'undefined-class' doesn't exist. Verify check registration. + Error: Class 'ClassUndefined' for check 'undefined-class' doesn't exist. Verify check registration. """ Scenario: Error when a check class doesn't extend our base class @@ -42,7 +42,7 @@ Feature: Configure the Doctor And a config.yml file: """ check space: - class: runcommand\Doctor\Checks\Constant_Definition + class: WP_CLI\Doctor\Check\ConstantDefinition """ When I try `wp doctor check --all --config=config.yml` @@ -56,7 +56,7 @@ Feature: Configure the Doctor And a config.yml file: """ constant-custom: - constant: Constant_Definition + constant: ConstantDefinition options: constant: CUSTOM defined: true @@ -73,7 +73,7 @@ Feature: Configure the Doctor And a config.yml file: """ constant-invalid-option: - check: Constant_Definition + check: ConstantDefinition options: constant_name: CUSTOM defined: true @@ -90,7 +90,7 @@ Feature: Configure the Doctor And a first-config.yml file: """ constant-wp-debug: - check: Constant_Definition + check: ConstantDefinition options: constant: WP_DEBUG falsy: true @@ -100,7 +100,7 @@ Feature: Configure the Doctor _: inherit: first-config.yml constant-savequeries: - check: Constant_Definition + check: ConstantDefinition options: constant: SAVEQUERIES falsy: true @@ -125,7 +125,7 @@ Feature: Configure the Doctor _: inherit: default constant-custom: - check: Constant_Definition + check: ConstantDefinition options: constant: CUSTOM defined: true @@ -164,7 +164,7 @@ Feature: Configure the Doctor And a config.yml file: """ plugin-akismet-valid-api-key: - class: Akismet_Valid_API_Key + class: AkismetValidApiKey require: akismet-valid-api-key.php """ And a akismet-valid-api-key.php file: @@ -173,7 +173,7 @@ Feature: Configure the Doctor /** * Ensures Akismet is activated with the appropriate credentials. */ - class Akismet_Valid_API_Key extends runcommand\Doctor\Checks\Check { + class AkismetValidApiKey extends WP_CLI\Doctor\Check { public function run() { // If the Akismet isn't activated, bail early. @@ -220,7 +220,7 @@ Feature: Configure the Doctor And a config.yml file: """ plugin-akismet-valid-api-key: - class: Akismet_Valid_API_Key + class: AkismetValidApiKey require: akismet-valid-api-key.php """ From c91e0fdf2eb146d3df79959dada5e979eadda86b Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 2 Nov 2023 15:58:41 +0100 Subject: [PATCH 04/28] Update error message --- features/check-plugin-status.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/check-plugin-status.feature b/features/check-plugin-status.feature index a9f7ce5..9c67bbf 100644 --- a/features/check-plugin-status.feature +++ b/features/check-plugin-status.feature @@ -80,5 +80,5 @@ Feature: Check the status of a plugin When I try `wp doctor check plugin-akismet-active-network --config=config.yml` Then STDERR should be: """ - Error: Invalid PluginStatus. Should be one of: uninstalled, installed, active. + Error: Invalid plugin_status. Should be one of: uninstalled, installed, active. """ From 7f23150929717c31e7e8054d2c803ffd4b0768fe Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 2 Nov 2023 16:12:43 +0100 Subject: [PATCH 05/28] Fix namespace --- src/Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Command.php b/src/Command.php index aa568f7..7420391 100644 --- a/src/Command.php +++ b/src/Command.php @@ -109,7 +109,7 @@ static function () use ( $name, $check, &$completed, &$progress ) { } ); } else { - $file_check = 'WP_CLI\Doctor\Checks\File'; + $file_check = 'WP_CLI\Doctor\Check\File'; if ( is_a( $check, $file_check ) || is_subclass_of( $check, $file_check ) ) { $file_checks[ $name ] = $check; } From 428e4726de96fe4050fb7c542f4621f9ae62db94 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 2 Nov 2023 16:12:54 +0100 Subject: [PATCH 06/28] Use const from base class --- src/Check/CacheFlush.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Check/CacheFlush.php b/src/Check/CacheFlush.php index e89bcf8..b8c376c 100644 --- a/src/Check/CacheFlush.php +++ b/src/Check/CacheFlush.php @@ -2,6 +2,7 @@ namespace WP_CLI\Doctor\Check; +use FilesystemIterator; use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use WP_CLI; @@ -12,10 +13,9 @@ class CacheFlush extends FileContents { public function run() { - // Path to wp-content directory. $wp_content_dir = defined( 'WP_CONTENT_DIR' ) ? WP_CONTENT_DIR : ABSPATH . 'wp-content'; - $directory = new RecursiveDirectoryIterator( $wp_content_dir, RecursiveDirectoryIterator::SKIP_DOTS ); + $directory = new RecursiveDirectoryIterator( $wp_content_dir, FilesystemIterator::SKIP_DOTS ); $iterator = new RecursiveIteratorIterator( $directory, RecursiveIteratorIterator::CHILD_FIRST ); // Regex to match. From 929a923dcf7cae557406af559141f68aa576517c Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 11:30:43 +0100 Subject: [PATCH 07/28] Make test more robust --- features/check-language-update.feature | 1 + 1 file changed, 1 insertion(+) diff --git a/features/check-language-update.feature b/features/check-language-update.feature index 09e22ee..cb1a746 100644 --- a/features/check-language-update.feature +++ b/features/check-language-update.feature @@ -36,6 +36,7 @@ Feature: Check whether languages are up to date When I run `wp language core install ja` And I run `cat wp-content/languages/custom.po > wp-content/languages/ja.po` + And I run `cat wp-content/languages/custom.po > wp-content/languages/admin-ja.po` When I run `wp doctor check language-update` Then STDOUT should be a table containing rows: From ac7a242ffe3abfd763f7be84f8175ab1fc0f2406 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 11:42:38 +0100 Subject: [PATCH 08/28] Update tests --- features/check-core-update.feature | 6 +++++- features/check-file-contents.feature | 2 +- features/check-plugin-active-count.feature | 12 +++++++++--- features/check-plugin-deactivated.feature | 2 ++ features/check.feature | 4 +++- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/features/check-core-update.feature b/features/check-core-update.feature index c14e5d7..eb4bd8e 100644 --- a/features/check-core-update.feature +++ b/features/check-core-update.feature @@ -16,9 +16,11 @@ Feature: Check whether WordPress is up to date | name | status | message | | core-update | success | WordPress is at the latest version. | + # This test downgrades to WordPress 5.9.0, but the SQLite plugin requires 6.0+ + @requires-mysql Scenario: WordPress has a new minor version but no new major version Given a WP install - And I run `wp core download --version=4.5.1 --force` + And I run `wp core download --version=5.9.0 --force` And I run `wp theme activate twentyfifteen` When I try `wp doctor check core-update` @@ -31,6 +33,8 @@ Feature: Check whether WordPress is up to date """ And the return code should be 1 + # This test downgrades to WordPress 5.9.0, but the SQLite plugin requires 6.0+ + @requires-mysql Scenario: WordPress has a new major version but no new minor version Given a WP install And I run `wp core download --version=4.4.9 --force` diff --git a/features/check-file-contents.feature b/features/check-file-contents.feature index 8263b97..76039a1 100644 --- a/features/check-file-contents.feature +++ b/features/check-file-contents.feature @@ -19,7 +19,7 @@ Feature: Check files in a WordPress install Given a wp-content/mu-plugins/exploited.php file: """ Date: Fri, 3 Nov 2023 11:59:10 +0100 Subject: [PATCH 09/28] Change version --- features/check-core-update.feature | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/features/check-core-update.feature b/features/check-core-update.feature index eb4bd8e..a23b061 100644 --- a/features/check-core-update.feature +++ b/features/check-core-update.feature @@ -16,11 +16,11 @@ Feature: Check whether WordPress is up to date | name | status | message | | core-update | success | WordPress is at the latest version. | - # This test downgrades to WordPress 5.9.0, but the SQLite plugin requires 6.0+ + # This test downgrades to WordPress 5.9.1, but the SQLite plugin requires 6.0+ @requires-mysql Scenario: WordPress has a new minor version but no new major version Given a WP install - And I run `wp core download --version=5.9.0 --force` + And I run `wp core download --version=5.9.1 --force` And I run `wp theme activate twentyfifteen` When I try `wp doctor check core-update` @@ -33,7 +33,7 @@ Feature: Check whether WordPress is up to date """ And the return code should be 1 - # This test downgrades to WordPress 5.9.0, but the SQLite plugin requires 6.0+ + # This test downgrades to WordPress 5.9.1, but the SQLite plugin requires 6.0+ @requires-mysql Scenario: WordPress has a new major version but no new minor version Given a WP install From e652614d2aa6241a25c4a23151263943a0b978b0 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 12:00:17 +0100 Subject: [PATCH 10/28] Update tests --- features/check-core-update.feature | 2 +- features/check-plugin-deactivated.feature | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/features/check-core-update.feature b/features/check-core-update.feature index a23b061..5be7e07 100644 --- a/features/check-core-update.feature +++ b/features/check-core-update.feature @@ -37,7 +37,7 @@ Feature: Check whether WordPress is up to date @requires-mysql Scenario: WordPress has a new major version but no new minor version Given a WP install - And I run `wp core download --version=4.4.9 --force` + And I run `wp core download --version=5.9.1 --force` And I run `wp theme activate twentyfifteen` When I try `wp doctor check core-update` diff --git a/features/check-plugin-deactivated.feature b/features/check-plugin-deactivated.feature index e224a4b..5d4ac0a 100644 --- a/features/check-plugin-deactivated.feature +++ b/features/check-plugin-deactivated.feature @@ -56,7 +56,9 @@ Feature: Check whether a high percentage of plugins are deactivated Scenario: Gracefully handle only network-enabled plugins installed and activated Given a WP multisite installation - And I run `wp plugin activate --network --all` + # Uses "try" because the SQLite plugin attempts to do a redirect. + # See https://github.com/WordPress/sqlite-database-integration/issues/49 + And I try `wp plugin activate --network --all` When I run `wp doctor check plugin-deactivated` Then STDOUT should be a table containing rows: From ff7e75274619ce33256ec9f143271e894984e2cb Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 12:12:34 +0100 Subject: [PATCH 11/28] Use twentytwenty which is available on 5.9 --- features/check-core-update.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/check-core-update.feature b/features/check-core-update.feature index 5be7e07..20e5d34 100644 --- a/features/check-core-update.feature +++ b/features/check-core-update.feature @@ -21,7 +21,7 @@ Feature: Check whether WordPress is up to date Scenario: WordPress has a new minor version but no new major version Given a WP install And I run `wp core download --version=5.9.1 --force` - And I run `wp theme activate twentyfifteen` + And I run `wp theme activate twentytwenty` When I try `wp doctor check core-update` Then STDOUT should be a table containing rows: @@ -38,7 +38,7 @@ Feature: Check whether WordPress is up to date Scenario: WordPress has a new major version but no new minor version Given a WP install And I run `wp core download --version=5.9.1 --force` - And I run `wp theme activate twentyfifteen` + And I run `wp theme activate twentytwenty` When I try `wp doctor check core-update` Then STDOUT should be a table containing rows: From 3dbb22a71fae0c72edcfcd9e5099897636559bc8 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 12:12:40 +0100 Subject: [PATCH 12/28] Make tests more robust --- features/check-plugin-active-count.feature | 10 ++++++++-- features/check-plugin-deactivated.feature | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/features/check-plugin-active-count.feature b/features/check-plugin-active-count.feature index 894a6c8..e74f197 100644 --- a/features/check-plugin-active-count.feature +++ b/features/check-plugin-active-count.feature @@ -14,10 +14,13 @@ Feature: Check whether a high number of plugins are activated # See https://github.com/WordPress/sqlite-database-integration/issues/49 And I try `wp plugin activate --all` + When I run `wp plugin_list --format=count` + Then save STDOUT as {PLUGIN_COUNT} + When I run `wp doctor check plugin-active-count` Then STDOUT should be a table containing rows: | name | status | message | - | plugin-active-count | success | Number of active plugins (2) is less than threshold (80). | + | plugin-active-count | success | Number of active plugins ({PLUGIN_COUNT}) is less than threshold (80). | Scenario: Greater than threshold plugins are active Given a WP install @@ -33,10 +36,13 @@ Feature: Check whether a high number of plugins are activated # See https://github.com/WordPress/sqlite-database-integration/issues/49 And I try `wp plugin activate --all` + When I run `wp plugin_list --format=count` + Then save STDOUT as {PLUGIN_COUNT} + When I run `wp doctor check plugin-active-count --config=config.yml` Then STDOUT should be a table containing rows: | name | status | message | - | plugin-active-count | warning | Number of active plugins (4) exceeds threshold (3). | + | plugin-active-count | warning | Number of active plugins ({PLUGIN_COUNT}) exceeds threshold (3). | Scenario: Include network-enabled plugins in active plugin count Given a WP multisite installation diff --git a/features/check-plugin-deactivated.feature b/features/check-plugin-deactivated.feature index 5d4ac0a..911f7d1 100644 --- a/features/check-plugin-deactivated.feature +++ b/features/check-plugin-deactivated.feature @@ -11,7 +11,9 @@ Feature: Check whether a high percentage of plugins are deactivated Scenario: All plugins are activated Given a WP install And I run `wp plugin install user-switching rewrite-rules-inspector` - And I run `wp plugin activate --all` + # Uses "try" because the SQLite plugin attempts to do a redirect. + # See https://github.com/WordPress/sqlite-database-integration/issues/49 + And I try `wp plugin activate --all` When I run `wp doctor check plugin-deactivated` Then STDOUT should be a table containing rows: From afca8a408698209ee20c9fd1107072a28aacf1f4 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 12:21:36 +0100 Subject: [PATCH 13/28] Fix typo --- features/check-plugin-active-count.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/check-plugin-active-count.feature b/features/check-plugin-active-count.feature index e74f197..2f696de 100644 --- a/features/check-plugin-active-count.feature +++ b/features/check-plugin-active-count.feature @@ -14,7 +14,7 @@ Feature: Check whether a high number of plugins are activated # See https://github.com/WordPress/sqlite-database-integration/issues/49 And I try `wp plugin activate --all` - When I run `wp plugin_list --format=count` + When I run `wp plugin list --format=count` Then save STDOUT as {PLUGIN_COUNT} When I run `wp doctor check plugin-active-count` @@ -36,7 +36,7 @@ Feature: Check whether a high number of plugins are activated # See https://github.com/WordPress/sqlite-database-integration/issues/49 And I try `wp plugin activate --all` - When I run `wp plugin_list --format=count` + When I run `wp plugin list --format=count` Then save STDOUT as {PLUGIN_COUNT} When I run `wp doctor check plugin-active-count --config=config.yml` From 817fd1990a0de6c42489716caa1ebc6e2ba459e7 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 12:53:47 +0100 Subject: [PATCH 14/28] Skip test --- features/check.feature | 3 +++ 1 file changed, 3 insertions(+) diff --git a/features/check.feature b/features/check.feature index 83bc8fb..4a5da94 100644 --- a/features/check.feature +++ b/features/check.feature @@ -1,5 +1,8 @@ Feature: Basic check usage + # The SQLite integration plugin uses wp_cache_flush() + # which means not all checks report success. + @require-mysql Scenario: Use --spotlight to focus on warnings and errors Given a WP install # Uses "try" because the SQLite plugin attempts to do a redirect. From 5e2953e967677a3a343ddfa125e4ad13b808475a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 12:57:07 +0100 Subject: [PATCH 15/28] Increase threshold --- features/check-plugin-active-count.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/check-plugin-active-count.feature b/features/check-plugin-active-count.feature index 2f696de..bf4d774 100644 --- a/features/check-plugin-active-count.feature +++ b/features/check-plugin-active-count.feature @@ -29,7 +29,7 @@ Feature: Check whether a high number of plugins are activated plugin-active-count: class: WP_CLI\Doctor\Check\PluginActiveCount options: - threshold_count: 3 + threshold_count: 4 """ And I run `wp plugin install user-switching rewrite-rules-inspector` # Uses "try" because the SQLite plugin attempts to do a redirect. @@ -42,7 +42,7 @@ Feature: Check whether a high number of plugins are activated When I run `wp doctor check plugin-active-count --config=config.yml` Then STDOUT should be a table containing rows: | name | status | message | - | plugin-active-count | warning | Number of active plugins ({PLUGIN_COUNT}) exceeds threshold (3). | + | plugin-active-count | warning | Number of active plugins ({PLUGIN_COUNT}) exceeds threshold (4). | Scenario: Include network-enabled plugins in active plugin count Given a WP multisite installation From b653227a0821408a78fee6e6972dadd04dbf3791 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 13:02:07 +0100 Subject: [PATCH 16/28] Reduce threshold --- features/check-plugin-active-count.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/check-plugin-active-count.feature b/features/check-plugin-active-count.feature index bf4d774..df5fe29 100644 --- a/features/check-plugin-active-count.feature +++ b/features/check-plugin-active-count.feature @@ -29,7 +29,7 @@ Feature: Check whether a high number of plugins are activated plugin-active-count: class: WP_CLI\Doctor\Check\PluginActiveCount options: - threshold_count: 4 + threshold_count: 2 """ And I run `wp plugin install user-switching rewrite-rules-inspector` # Uses "try" because the SQLite plugin attempts to do a redirect. @@ -42,7 +42,7 @@ Feature: Check whether a high number of plugins are activated When I run `wp doctor check plugin-active-count --config=config.yml` Then STDOUT should be a table containing rows: | name | status | message | - | plugin-active-count | warning | Number of active plugins ({PLUGIN_COUNT}) exceeds threshold (4). | + | plugin-active-count | warning | Number of active plugins ({PLUGIN_COUNT}) exceeds threshold (2). | Scenario: Include network-enabled plugins in active plugin count Given a WP multisite installation From c05a19f67fce558b321a6503b63c3eeb19a7d8bc Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 13:02:50 +0100 Subject: [PATCH 17/28] Fix alignment --- features/check-plugin-active-count.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/check-plugin-active-count.feature b/features/check-plugin-active-count.feature index df5fe29..2d1bf07 100644 --- a/features/check-plugin-active-count.feature +++ b/features/check-plugin-active-count.feature @@ -19,7 +19,7 @@ Feature: Check whether a high number of plugins are activated When I run `wp doctor check plugin-active-count` Then STDOUT should be a table containing rows: - | name | status | message | + | name | status | message | | plugin-active-count | success | Number of active plugins ({PLUGIN_COUNT}) is less than threshold (80). | Scenario: Greater than threshold plugins are active @@ -41,7 +41,7 @@ Feature: Check whether a high number of plugins are activated When I run `wp doctor check plugin-active-count --config=config.yml` Then STDOUT should be a table containing rows: - | name | status | message | + | name | status | message | | plugin-active-count | warning | Number of active plugins ({PLUGIN_COUNT}) exceeds threshold (2). | Scenario: Include network-enabled plugins in active plugin count From 8f1935cbca4dec78fcac8f82fdec06b8846df34c Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 13:59:57 +0100 Subject: [PATCH 18/28] Remove unused var --- src/Check/PluginActiveCount.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Check/PluginActiveCount.php b/src/Check/PluginActiveCount.php index 5bf8b21..2c17e11 100644 --- a/src/Check/PluginActiveCount.php +++ b/src/Check/PluginActiveCount.php @@ -17,8 +17,6 @@ class PluginActiveCount extends Plugin { protected $threshold_count = 80; public function run() { - $plugins = self::get_plugins(); - $active = 0; foreach ( self::get_plugins() as $plugin ) { if ( 'active' === $plugin['status'] || 'active-network' === $plugin['status'] ) { From d9928e0f01dbf2de1ae18cd4ebdeaa61bf875658 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 14:00:01 +0100 Subject: [PATCH 19/28] Add missing arg --- features/check-plugin-active-count.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/check-plugin-active-count.feature b/features/check-plugin-active-count.feature index 2d1bf07..1505597 100644 --- a/features/check-plugin-active-count.feature +++ b/features/check-plugin-active-count.feature @@ -14,7 +14,7 @@ Feature: Check whether a high number of plugins are activated # See https://github.com/WordPress/sqlite-database-integration/issues/49 And I try `wp plugin activate --all` - When I run `wp plugin list --format=count` + When I run `wp plugin list --status=active --format=count` Then save STDOUT as {PLUGIN_COUNT} When I run `wp doctor check plugin-active-count` @@ -36,7 +36,7 @@ Feature: Check whether a high number of plugins are activated # See https://github.com/WordPress/sqlite-database-integration/issues/49 And I try `wp plugin activate --all` - When I run `wp plugin list --format=count` + When I run `wp plugin list --status=active --format=count` Then save STDOUT as {PLUGIN_COUNT} When I run `wp doctor check plugin-active-count --config=config.yml` From 6ab4e4d71d27f98dd126a36f03c146b4d0dce9f3 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 14:01:07 +0100 Subject: [PATCH 20/28] Replace var --- features/check-plugin-active-count.feature | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/features/check-plugin-active-count.feature b/features/check-plugin-active-count.feature index 1505597..5b1a7f0 100644 --- a/features/check-plugin-active-count.feature +++ b/features/check-plugin-active-count.feature @@ -50,7 +50,10 @@ Feature: Check whether a high number of plugins are activated # See https://github.com/WordPress/sqlite-database-integration/issues/49 And I try `wp plugin activate --network --all` + When I run `wp plugin list --status=active --format=count` + Then save STDOUT as {PLUGIN_COUNT} + When I run `wp doctor check plugin-active-count` Then STDOUT should be a table containing rows: | name | status | message | - | plugin-active-count | success | Number of active plugins (2) is less than threshold (80). | + | plugin-active-count | success | Number of active plugins ({PLUGIN_COUNT}) is less than threshold (80). | From e27c3b9864309ed051a9b0752ad64bc2b1012922 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 14:07:15 +0100 Subject: [PATCH 21/28] List network-active plugins --- features/check-plugin-active-count.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/check-plugin-active-count.feature b/features/check-plugin-active-count.feature index 5b1a7f0..df201c5 100644 --- a/features/check-plugin-active-count.feature +++ b/features/check-plugin-active-count.feature @@ -50,7 +50,7 @@ Feature: Check whether a high number of plugins are activated # See https://github.com/WordPress/sqlite-database-integration/issues/49 And I try `wp plugin activate --network --all` - When I run `wp plugin list --status=active --format=count` + When I run `wp plugin list --status=active-network --format=count` Then save STDOUT as {PLUGIN_COUNT} When I run `wp doctor check plugin-active-count` From 0fa8a7cd912d79525b2beae27dc20cdd48b8a180 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 3 Nov 2023 14:15:58 +0100 Subject: [PATCH 22/28] Update tests --- features/check-core-update.feature | 1 + features/check-file-contents.feature | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/features/check-core-update.feature b/features/check-core-update.feature index 20e5d34..c181d10 100644 --- a/features/check-core-update.feature +++ b/features/check-core-update.feature @@ -8,6 +8,7 @@ Feature: Check whether WordPress is up to date | name | description | | core-update | Errors when new WordPress minor release is available; warns for major release. | + @require-wp-latest Scenario: WordPress is up to date Given a WP install diff --git a/features/check-file-contents.feature b/features/check-file-contents.feature index 76039a1..3503023 100644 --- a/features/check-file-contents.feature +++ b/features/check-file-contents.feature @@ -19,7 +19,7 @@ Feature: Check files in a WordPress install Given a wp-content/mu-plugins/exploited.php file: """ Date: Sat, 4 Nov 2023 15:41:24 +0100 Subject: [PATCH 23/28] Fix property name --- src/Checks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Checks.php b/src/Checks.php index a2d32d0..d13f9b7 100644 --- a/src/Checks.php +++ b/src/Checks.php @@ -10,8 +10,8 @@ class Checks { private static $instance; - private $checks = array(); - private $skipped = array(); + private $checks = array(); + private $skipped_checks = array(); public static function get_instance() { if ( ! isset( self::$instance ) ) { From e514ffe66abe142180952b32f5f7cffac87976e4 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Sat, 4 Nov 2023 15:41:34 +0100 Subject: [PATCH 24/28] Rename classes to add back underscores --- doctor.yml | 32 +++++++++---------- features/check-autoload-options-size.feature | 2 +- features/check-constant-definition.feature | 6 ++-- features/check-file-contents.feature | 6 ++-- features/check-file-type.feature | 4 +-- features/check-option-value.feature | 12 +++---- features/check-plugin-active-count.feature | 2 +- features/check-plugin-deactivated.feature | 2 +- features/check-plugin-status.feature | 8 ++--- features/config.feature | 10 +++--- ...ionsSize.php => Autoload_Options_Size.php} | 2 +- src/Check/{CacheFlush.php => Cache_Flush.php} | 2 +- ...Definition.php => Constant_Definition.php} | 2 +- src/Check/{CoreUpdate.php => Core_Update.php} | 2 +- ...hecksums.php => Core_Verify_Checksums.php} | 2 +- src/Check/{CronCount.php => Cron_Count.php} | 2 +- ...CronDuplicates.php => Cron_Duplicates.php} | 2 +- .../{FileContents.php => File_Contents.php} | 2 +- src/Check/{FileType.php => File_Type.php} | 2 +- ...LanguageUpdate.php => Language_Update.php} | 2 +- .../{OptionValue.php => Option_Value.php} | 2 +- .../{PHPInUpload.php => PHP_In_Upload.php} | 2 +- ...ctiveCount.php => Plugin_Active_Count.php} | 2 +- ...Deactivated.php => Plugin_Deactivated.php} | 2 +- .../{PluginStatus.php => Plugin_Status.php} | 2 +- .../{PluginUpdate.php => Plugin_Update.php} | 2 +- .../{ThemeUpdate.php => Theme_Update.php} | 2 +- 27 files changed, 59 insertions(+), 59 deletions(-) rename src/Check/{AutoloadOptionsSize.php => Autoload_Options_Size.php} (96%) rename src/Check/{CacheFlush.php => Cache_Flush.php} (95%) rename src/Check/{ConstantDefinition.php => Constant_Definition.php} (98%) rename src/Check/{CoreUpdate.php => Core_Update.php} (96%) rename src/Check/{CoreVerifyChecksums.php => Core_Verify_Checksums.php} (94%) rename src/Check/{CronCount.php => Cron_Count.php} (95%) rename src/Check/{CronDuplicates.php => Cron_Duplicates.php} (96%) rename src/Check/{FileContents.php => File_Contents.php} (98%) rename src/Check/{FileType.php => File_Type.php} (97%) rename src/Check/{LanguageUpdate.php => Language_Update.php} (96%) rename src/Check/{OptionValue.php => Option_Value.php} (98%) rename src/Check/{PHPInUpload.php => PHP_In_Upload.php} (96%) rename src/Check/{PluginActiveCount.php => Plugin_Active_Count.php} (94%) rename src/Check/{PluginDeactivated.php => Plugin_Deactivated.php} (95%) rename src/Check/{PluginStatus.php => Plugin_Status.php} (97%) rename src/Check/{PluginUpdate.php => Plugin_Update.php} (94%) rename src/Check/{ThemeUpdate.php => Theme_Update.php} (96%) diff --git a/doctor.yml b/doctor.yml index 370a09f..bf8fbf9 100644 --- a/doctor.yml +++ b/doctor.yml @@ -1,44 +1,44 @@ # Default check configuration for `wp doctor` autoload-options-size: - check: AutoloadOptionsSize + check: Autoload_Options_Size constant-savequeries-falsy: - check: ConstantDefinition + check: Constant_Definition options: constant: SAVEQUERIES falsy: true constant-wp-debug-falsy: - check: ConstantDefinition + check: Constant_Definition options: constant: WP_DEBUG falsy: true core-update: - check: CoreUpdate + check: Core_Update core-verify-checksums: - check: CoreVerifyChecksums + check: Core_Verify_Checksums cron-count: - check: CronCount + check: Cron_Count cron-duplicates: - check: CronDuplicates + check: Cron_Duplicates file-eval: - check: FileContents + check: File_Contents options: regex: eval\(.*base64_decode\(.* option-blog-public: - check: OptionValue + check: Option_Value options: option: blog_public value: 1 plugin-active-count: - check: PluginActiveCount + check: Plugin_Active_Count plugin-deactivated: - check: PluginDeactivated + check: Plugin_Deactivated plugin-update: - check: PluginUpdate + check: Plugin_Update theme-update: - check: ThemeUpdate + check: Theme_Update cache-flush: - check: CacheFlush + check: Cache_Flush php-in-upload: - check: PHPInUpload + check: PHP_In_Upload language-update: - check: LanguageUpdate + check: Language_Update diff --git a/features/check-autoload-options-size.feature b/features/check-autoload-options-size.feature index 07b98f8..2f8d4f7 100644 --- a/features/check-autoload-options-size.feature +++ b/features/check-autoload-options-size.feature @@ -50,7 +50,7 @@ Feature: Check the size of autoloaded options And a custom.yml file: """ autoload-options-size: - class: WP_CLI\Doctor\Check\AutoloadOptionsSize + class: WP_CLI\Doctor\Check\Autoload_Options_Size options: threshold_kb: 800 """ diff --git a/features/check-constant-definition.feature b/features/check-constant-definition.feature index a6f7959..0695ea5 100644 --- a/features/check-constant-definition.feature +++ b/features/check-constant-definition.feature @@ -71,7 +71,7 @@ Feature: Check the values of defined constants And a config.yml file: """ constant-db-host-defined: - class: WP_CLI\Doctor\Check\ConstantDefinition + class: WP_CLI\Doctor\Check\Constant_Definition options: constant: DB_HOST defined: true @@ -87,7 +87,7 @@ Feature: Check the values of defined constants And a config.yml file: """ constant-foobar-true: - class: WP_CLI\Doctor\Check\ConstantDefinition + class: WP_CLI\Doctor\Check\Constant_Definition options: constant: FOOBAR value: true @@ -108,7 +108,7 @@ Feature: Check the values of defined constants And a config.yml file: """ constant-foobar-true: - class: WP_CLI\Doctor\Check\ConstantDefinition + class: WP_CLI\Doctor\Check\Constant_Definition options: constant: FOOBAR value: true diff --git a/features/check-file-contents.feature b/features/check-file-contents.feature index 3503023..9a5b1dd 100644 --- a/features/check-file-contents.feature +++ b/features/check-file-contents.feature @@ -37,7 +37,7 @@ Feature: Check files in a WordPress install And a config.yml file: """ file-sessions: - check: FileContents + check: File_Contents options: regex: .*(session_start|\$_SESSION).* only_wp_content: true @@ -74,7 +74,7 @@ Feature: Check files in a WordPress install And a config.yml file: """ file-server-name-wp-config: - check: FileContents + check: File_Contents options: regex: define\(.+WP_(HOME|SITEURL).+\$_SERVER.+SERVER_NAME path: wp-config.php @@ -122,7 +122,7 @@ Feature: Check files in a WordPress install And a config.yml file: """ file-content-exist: - check: FileContents + check: File_Contents options: regex: .*wp-doctor-exists-test.* only_wp_content: true diff --git a/features/check-file-type.feature b/features/check-file-type.feature index 78bbf27..009801b 100644 --- a/features/check-file-type.feature +++ b/features/check-file-type.feature @@ -5,7 +5,7 @@ Feature: Check the type of file And a config.yml file: """ file-object-cache-symlink: - check: FileType + check: File_Type options: path: wp-content/object-cache.php symlink: false @@ -38,7 +38,7 @@ Feature: Check the type of file And a config.yml file: """ file-object-cache-symlink: - check: FileType + check: File_Type options: path: wp-content/object-cache.php symlink: true diff --git a/features/check-option-value.feature b/features/check-option-value.feature index 35ad3c3..af42c5a 100644 --- a/features/check-option-value.feature +++ b/features/check-option-value.feature @@ -13,7 +13,7 @@ Feature: Check the value of a given option And a blog-private.yml file: """ option-blog-private: - check: OptionValue + check: Option_Value options: option: blog_public value: 0 @@ -21,7 +21,7 @@ Feature: Check the value of a given option And a blog-public.yml file: """ option-blog-public: - check: OptionValue + check: Option_Value options: option: blog_public value: 1 @@ -74,7 +74,7 @@ Feature: Check the value of a given option And a config.yml file: """ option-admin-email: - check: OptionValue + check: Option_Value options: option: admin_email value: foo@example.org @@ -106,7 +106,7 @@ Feature: Check the value of a given option And a config.yml file: """ option-admin-email: - check: OptionValue + check: Option_Value options: option: admin_email value_is_not: foo@example.org @@ -139,7 +139,7 @@ Feature: Check the value of a given option And a config.yml file: """ option-users-can-register: - check: OptionValue + check: Option_Value options: option: users_can_register value: 0 @@ -172,7 +172,7 @@ Feature: Check the value of a given option And a config.yml file: """ option-users-can-register: - check: OptionValue + check: Option_Value options: option: users_can_register value: 0 diff --git a/features/check-plugin-active-count.feature b/features/check-plugin-active-count.feature index df201c5..2dfbd1f 100644 --- a/features/check-plugin-active-count.feature +++ b/features/check-plugin-active-count.feature @@ -27,7 +27,7 @@ Feature: Check whether a high number of plugins are activated And a config.yml file: """ plugin-active-count: - class: WP_CLI\Doctor\Check\PluginActiveCount + class: WP_CLI\Doctor\Check\Plugin_Active_Count options: threshold_count: 2 """ diff --git a/features/check-plugin-deactivated.feature b/features/check-plugin-deactivated.feature index 911f7d1..c3b8aad 100644 --- a/features/check-plugin-deactivated.feature +++ b/features/check-plugin-deactivated.feature @@ -34,7 +34,7 @@ Feature: Check whether a high percentage of plugins are deactivated And a custom.yml file: """ plugin-deactivated: - class: WP_CLI\Doctor\Check\PluginDeactivated + class: WP_CLI\Doctor\Check\Plugin_Deactivated options: threshold_percentage: 60 """ diff --git a/features/check-plugin-status.feature b/features/check-plugin-status.feature index 9c67bbf..8e705ec 100644 --- a/features/check-plugin-status.feature +++ b/features/check-plugin-status.feature @@ -5,7 +5,7 @@ Feature: Check the status of a plugin And a config.yml file: """ plugin-akismet-active: - class: WP_CLI\Doctor\Check\PluginStatus + class: WP_CLI\Doctor\Check\Plugin_Status options: name: akismet status: active @@ -21,12 +21,12 @@ Feature: Check the status of a plugin And a config.yml file: """ plugin-akismet-active: - class: WP_CLI\Doctor\Check\PluginStatus + class: WP_CLI\Doctor\Check\Plugin_Status options: name: akismet status: active plugin-hello-uninstalled: - class: WP_CLI\Doctor\Check\PluginStatus + class: WP_CLI\Doctor\Check\Plugin_Status options: name: hello status: uninstalled @@ -71,7 +71,7 @@ Feature: Check the status of a plugin And a config.yml file: """ plugin-akismet-active-network: - class: WP_CLI\Doctor\Check\PluginStatus + class: WP_CLI\Doctor\Check\Plugin_Status options: name: akismet status: active-network diff --git a/features/config.feature b/features/config.feature index 43c33d5..642876c 100644 --- a/features/config.feature +++ b/features/config.feature @@ -42,7 +42,7 @@ Feature: Configure the Doctor And a config.yml file: """ check space: - class: WP_CLI\Doctor\Check\ConstantDefinition + class: WP_CLI\Doctor\Check\Constant_Definition """ When I try `wp doctor check --all --config=config.yml` @@ -73,7 +73,7 @@ Feature: Configure the Doctor And a config.yml file: """ constant-invalid-option: - check: ConstantDefinition + check: Constant_Definition options: constant_name: CUSTOM defined: true @@ -90,7 +90,7 @@ Feature: Configure the Doctor And a first-config.yml file: """ constant-wp-debug: - check: ConstantDefinition + check: Constant_Definition options: constant: WP_DEBUG falsy: true @@ -100,7 +100,7 @@ Feature: Configure the Doctor _: inherit: first-config.yml constant-savequeries: - check: ConstantDefinition + check: Constant_Definition options: constant: SAVEQUERIES falsy: true @@ -125,7 +125,7 @@ Feature: Configure the Doctor _: inherit: default constant-custom: - check: ConstantDefinition + check: Constant_Definition options: constant: CUSTOM defined: true diff --git a/src/Check/AutoloadOptionsSize.php b/src/Check/Autoload_Options_Size.php similarity index 96% rename from src/Check/AutoloadOptionsSize.php rename to src/Check/Autoload_Options_Size.php index 42911ef..db2437d 100644 --- a/src/Check/AutoloadOptionsSize.php +++ b/src/Check/Autoload_Options_Size.php @@ -8,7 +8,7 @@ /** * Warns when autoloaded options size exceeds threshold of %threshold_kb% kb. */ -class AutoloadOptionsSize extends Check { +class Autoload_Options_Size extends Check { /** * Threshold in kilobytes. diff --git a/src/Check/CacheFlush.php b/src/Check/Cache_Flush.php similarity index 95% rename from src/Check/CacheFlush.php rename to src/Check/Cache_Flush.php index b8c376c..2b733c7 100644 --- a/src/Check/CacheFlush.php +++ b/src/Check/Cache_Flush.php @@ -10,7 +10,7 @@ /** * Detects any use of the `wp_cache_flush()` function. */ -class CacheFlush extends FileContents { +class Cache_Flush extends File_Contents { public function run() { // Path to wp-content directory. diff --git a/src/Check/ConstantDefinition.php b/src/Check/Constant_Definition.php similarity index 98% rename from src/Check/ConstantDefinition.php rename to src/Check/Constant_Definition.php index 4b6fbe3..9799661 100644 --- a/src/Check/ConstantDefinition.php +++ b/src/Check/Constant_Definition.php @@ -8,7 +8,7 @@ /** * Confirms expected state of the %constant% constant. */ -class ConstantDefinition extends Check { +class Constant_Definition extends Check { /** * Name of the constant. diff --git a/src/Check/CoreUpdate.php b/src/Check/Core_Update.php similarity index 96% rename from src/Check/CoreUpdate.php rename to src/Check/Core_Update.php index 90e4ac4..55d4c4d 100644 --- a/src/Check/CoreUpdate.php +++ b/src/Check/Core_Update.php @@ -8,7 +8,7 @@ /** * Errors when new WordPress minor release is available; warns for major release. */ -class CoreUpdate extends Check { +class Core_Update extends Check { public function run() { ob_start(); diff --git a/src/Check/CoreVerifyChecksums.php b/src/Check/Core_Verify_Checksums.php similarity index 94% rename from src/Check/CoreVerifyChecksums.php rename to src/Check/Core_Verify_Checksums.php index 0ae03ff..3b7abdf 100644 --- a/src/Check/CoreVerifyChecksums.php +++ b/src/Check/Core_Verify_Checksums.php @@ -8,7 +8,7 @@ /** * Verifies WordPress files against published checksums; errors on failure. */ -class CoreVerifyChecksums extends Check { +class Core_Verify_Checksums extends Check { public function __construct( $options = array() ) { parent::__construct( $options ); diff --git a/src/Check/CronCount.php b/src/Check/Cron_Count.php similarity index 95% rename from src/Check/CronCount.php rename to src/Check/Cron_Count.php index bdc40f3..e9d943a 100644 --- a/src/Check/CronCount.php +++ b/src/Check/Cron_Count.php @@ -7,7 +7,7 @@ /** * Errors when there's an excess of %threshold_count% total cron jobs registered. */ -class CronCount extends Cron { +class Cron_Count extends Cron { /** * Warn when there are greater than this number of cron jobs. diff --git a/src/Check/CronDuplicates.php b/src/Check/Cron_Duplicates.php similarity index 96% rename from src/Check/CronDuplicates.php rename to src/Check/Cron_Duplicates.php index 6a0c735..08c1cbf 100644 --- a/src/Check/CronDuplicates.php +++ b/src/Check/Cron_Duplicates.php @@ -7,7 +7,7 @@ /** * Errors when there's an excess of %threshold_count% duplicate cron jobs registered. */ -class CronDuplicates extends Cron { +class Cron_Duplicates extends Cron { /** * Warn when there are greater than this number of duplicates. diff --git a/src/Check/FileContents.php b/src/Check/File_Contents.php similarity index 98% rename from src/Check/FileContents.php rename to src/Check/File_Contents.php index 1c2c428..4927c08 100644 --- a/src/Check/FileContents.php +++ b/src/Check/File_Contents.php @@ -7,7 +7,7 @@ /** * Checks files on the filesystem for regex pattern `%regex%`. */ -class FileContents extends File { +class File_Contents extends File { /** * Regex pattern to check against each file’s contents. diff --git a/src/Check/FileType.php b/src/Check/File_Type.php similarity index 97% rename from src/Check/FileType.php rename to src/Check/File_Type.php index beb9ae1..1a161f1 100644 --- a/src/Check/FileType.php +++ b/src/Check/File_Type.php @@ -7,7 +7,7 @@ /** * Checks files on the filesystem to be of a certain type. */ -class FileType extends File { +class File_Type extends File { /** * Assert the file type is or isn't a symlink. diff --git a/src/Check/LanguageUpdate.php b/src/Check/Language_Update.php similarity index 96% rename from src/Check/LanguageUpdate.php rename to src/Check/Language_Update.php index dfb44ff..ec12882 100644 --- a/src/Check/LanguageUpdate.php +++ b/src/Check/Language_Update.php @@ -8,7 +8,7 @@ /** * Warns when there are language updates available. */ -class LanguageUpdate extends Check { +class Language_Update extends Check { public function run() { diff --git a/src/Check/OptionValue.php b/src/Check/Option_Value.php similarity index 98% rename from src/Check/OptionValue.php rename to src/Check/Option_Value.php index 43158dd..f4b5ee5 100644 --- a/src/Check/OptionValue.php +++ b/src/Check/Option_Value.php @@ -8,7 +8,7 @@ /** * Confirms the expected value of the '%option%' option. */ -class OptionValue extends Check { +class Option_Value extends Check { /** * Name of the option. diff --git a/src/Check/PHPInUpload.php b/src/Check/PHP_In_Upload.php similarity index 96% rename from src/Check/PHPInUpload.php rename to src/Check/PHP_In_Upload.php index 419c53e..1ee16f1 100644 --- a/src/Check/PHPInUpload.php +++ b/src/Check/PHP_In_Upload.php @@ -10,7 +10,7 @@ /** * Warns when a PHP file is present in the Uploads folder. */ -class PHPInUpload extends Check { +class PHP_In_Upload extends Check { /** * Array containing list of files found in the uploads folder diff --git a/src/Check/PluginActiveCount.php b/src/Check/Plugin_Active_Count.php similarity index 94% rename from src/Check/PluginActiveCount.php rename to src/Check/Plugin_Active_Count.php index 2c17e11..6295664 100644 --- a/src/Check/PluginActiveCount.php +++ b/src/Check/Plugin_Active_Count.php @@ -7,7 +7,7 @@ /** * Warns when there are greater than %threshold_count% plugins activated. */ -class PluginActiveCount extends Plugin { +class Plugin_Active_Count extends Plugin { /** * Threshold as a total number of plugins. diff --git a/src/Check/PluginDeactivated.php b/src/Check/Plugin_Deactivated.php similarity index 95% rename from src/Check/PluginDeactivated.php rename to src/Check/Plugin_Deactivated.php index f7abf67..02458ee 100644 --- a/src/Check/PluginDeactivated.php +++ b/src/Check/Plugin_Deactivated.php @@ -7,7 +7,7 @@ /** * Warns when greater than %threshold_percentage%% of plugins are deactivated. */ -class PluginDeactivated extends Plugin { +class Plugin_Deactivated extends Plugin { /** * Threshold as a percentage. diff --git a/src/Check/PluginStatus.php b/src/Check/Plugin_Status.php similarity index 97% rename from src/Check/PluginStatus.php rename to src/Check/Plugin_Status.php index 40525ea..20e5fe0 100644 --- a/src/Check/PluginStatus.php +++ b/src/Check/Plugin_Status.php @@ -7,7 +7,7 @@ /** * Errors if plugin '%name%' isn't in the expected state '%status%'. */ -class PluginStatus extends Plugin { +class Plugin_Status extends Plugin { /** * Name of the plugin to check. diff --git a/src/Check/PluginUpdate.php b/src/Check/Plugin_Update.php similarity index 94% rename from src/Check/PluginUpdate.php rename to src/Check/Plugin_Update.php index 3c0555a..6443450 100644 --- a/src/Check/PluginUpdate.php +++ b/src/Check/Plugin_Update.php @@ -7,7 +7,7 @@ /** * Warns when there are plugin updates available. */ -class PluginUpdate extends Plugin { +class Plugin_Update extends Plugin { public function run() { $plugins = self::get_plugins(); diff --git a/src/Check/ThemeUpdate.php b/src/Check/Theme_Update.php similarity index 96% rename from src/Check/ThemeUpdate.php rename to src/Check/Theme_Update.php index 409905c..dd3a679 100644 --- a/src/Check/ThemeUpdate.php +++ b/src/Check/Theme_Update.php @@ -8,7 +8,7 @@ /** * Warns when there are theme updates available. */ -class ThemeUpdate extends Check { +class Theme_Update extends Check { public function run() { ob_start(); From e899630f39496bd1ef3d83f1a9673ca3c3caf9d8 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 6 Nov 2023 13:16:52 +0100 Subject: [PATCH 25/28] Run `wp core update` --- features/check-core-update.feature | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/check-core-update.feature b/features/check-core-update.feature index c181d10..ef34af4 100644 --- a/features/check-core-update.feature +++ b/features/check-core-update.feature @@ -12,7 +12,8 @@ Feature: Check whether WordPress is up to date Scenario: WordPress is up to date Given a WP install - When I run `wp doctor check core-update` + When I run `wp core update` + And I run `wp doctor check core-update` Then STDOUT should be a table containing rows: | name | status | message | | core-update | success | WordPress is at the latest version. | From 2dcfb1c6d5cf429fe953935f2e4e55cd87ab8f70 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 6 Nov 2023 13:18:05 +0100 Subject: [PATCH 26/28] Update another test --- features/check.feature | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/features/check.feature b/features/check.feature index 4a5da94..cb15ed8 100644 --- a/features/check.feature +++ b/features/check.feature @@ -2,9 +2,10 @@ Feature: Basic check usage # The SQLite integration plugin uses wp_cache_flush() # which means not all checks report success. - @require-mysql + @require-wp-latest @require-mysql Scenario: Use --spotlight to focus on warnings and errors Given a WP install + And I run `wp core update` # Uses "try" because the SQLite plugin attempts to do a redirect. # See https://github.com/WordPress/sqlite-database-integration/issues/49 And I try `wp plugin activate --all` From f07dd9c9c25996a7e501e8e4df9aaec323f7fcf6 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 6 Nov 2023 13:26:24 +0100 Subject: [PATCH 27/28] Remove step again --- features/check-core-update.feature | 1 - features/check.feature | 1 - 2 files changed, 2 deletions(-) diff --git a/features/check-core-update.feature b/features/check-core-update.feature index ef34af4..605b519 100644 --- a/features/check-core-update.feature +++ b/features/check-core-update.feature @@ -12,7 +12,6 @@ Feature: Check whether WordPress is up to date Scenario: WordPress is up to date Given a WP install - When I run `wp core update` And I run `wp doctor check core-update` Then STDOUT should be a table containing rows: | name | status | message | diff --git a/features/check.feature b/features/check.feature index cb15ed8..ef50d1c 100644 --- a/features/check.feature +++ b/features/check.feature @@ -5,7 +5,6 @@ Feature: Basic check usage @require-wp-latest @require-mysql Scenario: Use --spotlight to focus on warnings and errors Given a WP install - And I run `wp core update` # Uses "try" because the SQLite plugin attempts to do a redirect. # See https://github.com/WordPress/sqlite-database-integration/issues/49 And I try `wp plugin activate --all` From 1ede25aa3f2edeb65ee0a6197ec3a929f80b3c9a Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 7 Nov 2023 15:39:54 +0100 Subject: [PATCH 28/28] Only _try_ update --- features/check-core-update.feature | 1 + features/check.feature | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/features/check-core-update.feature b/features/check-core-update.feature index 605b519..2660249 100644 --- a/features/check-core-update.feature +++ b/features/check-core-update.feature @@ -12,6 +12,7 @@ Feature: Check whether WordPress is up to date Scenario: WordPress is up to date Given a WP install + When I try `wp core update` And I run `wp doctor check core-update` Then STDOUT should be a table containing rows: | name | status | message | diff --git a/features/check.feature b/features/check.feature index ef50d1c..8d0f04b 100644 --- a/features/check.feature +++ b/features/check.feature @@ -14,7 +14,8 @@ Feature: Basic check usage When I run `wp doctor list --format=count` Then save STDOUT as {CHECK_COUNT} - When I run `wp doctor check --all --spotlight` + When I try `wp core update` + And I run `wp doctor check --all --spotlight` Then STDOUT should be: """ Success: All {CHECK_COUNT} checks report 'success'.