From a26035209fb013bc4a672af595637d7f15ab08bf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 22:35:44 +0000 Subject: [PATCH 1/4] Initial plan From a3ccc4d77da8a9513538d68ba8265025127b5582 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 22:39:11 +0000 Subject: [PATCH 2/4] Add --verbose flag for doctor check command Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/check.feature | 44 ++++++++++++++++++++++++++++++++++++++++++ src/Command.php | 36 +++++++++++++++++++++++++++++++--- 2 files changed, 77 insertions(+), 3 deletions(-) diff --git a/features/check.feature b/features/check.feature index 998e054..e1641e0 100644 --- a/features/check.feature +++ b/features/check.feature @@ -185,3 +185,47 @@ Feature: Basic check usage And STDOUT should be a table containing rows: | name | status | | autoload-options-size | success | + + Scenario: Use --verbose flag to see check progress + Given a WP install + + When I run `wp doctor check autoload-options-size --verbose` + Then STDOUT should contain: + """ + Running check: autoload-options-size + """ + And STDOUT should contain: + """ + Status: + """ + + Scenario: Use --verbose flag with multiple checks + Given a WP install + + When I run `wp doctor check autoload-options-size core-update --verbose` + Then STDOUT should contain: + """ + Running check: autoload-options-size + """ + And STDOUT should contain: + """ + Running check: core-update + """ + + Scenario: Use --verbose flag with file checks + Given a WP install + And a wp-content/uploads/foo.php file: + """ + $args ) ); if ( empty( $checks ) ) { @@ -125,7 +130,7 @@ public function check( $args, $assoc_args ) { } $file_checks = array(); $progress = false; - if ( $all && 'table' === $assoc_args['format'] ) { + if ( $all && 'table' === $assoc_args['format'] && ! $verbose ) { $progress = Utils\make_progress_bar( 'Running checks', count( $checks ) ); } foreach ( $checks as $name => $check ) { @@ -133,12 +138,19 @@ public function check( $args, $assoc_args ) { if ( $when ) { WP_CLI::add_hook( $when, - static function () use ( $name, $check, &$completed, &$progress ) { + static function () use ( $name, $check, &$completed, &$progress, $verbose ) { + if ( $verbose ) { + WP_CLI::log( "Running check: {$name}" ); + } $check->run(); $completed[ $name ] = $check; if ( $progress ) { $progress->tick(); } + if ( $verbose ) { + $results = $check->get_results(); + WP_CLI::log( " Status: {$results['status']}" ); + } } ); } else { @@ -151,12 +163,20 @@ static function () use ( $name, $check, &$completed, &$progress ) { if ( ! empty( $file_checks ) ) { WP_CLI::add_hook( 'after_wp_config_load', - static function () use ( $file_checks, &$completed, &$progress ) { + static function () use ( $file_checks, &$completed, &$progress, $verbose ) { + if ( $verbose ) { + WP_CLI::log( 'Scanning filesystem for file checks...' ); + } try { $directory = new RecursiveDirectoryIterator( ABSPATH, RecursiveDirectoryIterator::SKIP_DOTS ); $iterator = new RecursiveIteratorIterator( $directory, RecursiveIteratorIterator::CHILD_FIRST ); $wp_content_dir = defined( 'WP_CONTENT_DIR' ) ? WP_CONTENT_DIR : ABSPATH . 'wp-content'; + $file_count = 0; foreach ( $iterator as $file ) { + ++$file_count; + if ( $verbose && 0 === $file_count % 1000 ) { + WP_CLI::log( " Scanned {$file_count} files..." ); + } foreach ( $file_checks as $name => $check ) { $options = $check->get_options(); if ( ! empty( $options['only_wp_content'] ) @@ -174,15 +194,25 @@ static function () use ( $file_checks, &$completed, &$progress ) { $check->check_file( $file ); } } + if ( $verbose ) { + WP_CLI::log( " Total files scanned: {$file_count}" ); + } } catch ( Exception $e ) { WP_CLI::warning( $e->getMessage() ); } foreach ( $file_checks as $name => $check ) { + if ( $verbose ) { + WP_CLI::log( "Running check: {$name}" ); + } $check->run(); $completed[ $name ] = $check; if ( $progress ) { $progress->tick(); } + if ( $verbose ) { + $results = $check->get_results(); + WP_CLI::log( " Status: {$results['status']}" ); + } } } ); From 2aa3efe410a13ed00fa4bc3d8bc0a2b0a541b3d6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 22:40:57 +0000 Subject: [PATCH 3/4] Extract magic number to named constant Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/Command.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Command.php b/src/Command.php index b9f41d7..b5dd82c 100644 --- a/src/Command.php +++ b/src/Command.php @@ -36,6 +36,11 @@ */ class Command { + /** + * Number of files to scan before showing progress in verbose mode. + */ + const VERBOSE_FILE_SCAN_INTERVAL = 1000; + /** * Run a series of checks against WordPress to diagnose issues. * @@ -174,7 +179,7 @@ static function () use ( $file_checks, &$completed, &$progress, $verbose ) { $file_count = 0; foreach ( $iterator as $file ) { ++$file_count; - if ( $verbose && 0 === $file_count % 1000 ) { + if ( $verbose && 0 === $file_count % self::VERBOSE_FILE_SCAN_INTERVAL ) { WP_CLI::log( " Scanned {$file_count} files..." ); } foreach ( $file_checks as $name => $check ) { From 2a2a5fac664db8e732dad99dc4bb5a24c03ceec5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Feb 2026 17:05:38 +0000 Subject: [PATCH 4/4] Fix test: use file-based check instead of php-in-upload Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/check.feature | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/features/check.feature b/features/check.feature index e1641e0..b88d834 100644 --- a/features/check.feature +++ b/features/check.feature @@ -214,18 +214,20 @@ Feature: Basic check usage Scenario: Use --verbose flag with file checks Given a WP install - And a wp-content/uploads/foo.php file: + And a wp-content/plugins/foo.php file: """