From 902217521ae41c522cd012745c269e8a6bd96926 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 1 Nov 2025 20:10:12 +0000 Subject: [PATCH 1/3] Initial plan From dd22d6169320e669fcbb8fbd07f30111917c5ecf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 1 Nov 2025 20:27:56 +0000 Subject: [PATCH 2/3] Fix ignored_paths false positives by matching at directory boundaries Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- features/find.feature | 41 +++++++++++++++++++++++++++++++++++++++++ src/Find_Command.php | 3 ++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/features/find.feature b/features/find.feature index 7b2cb92..ae50d10 100644 --- a/features/find.feature +++ b/features/find.feature @@ -217,3 +217,44 @@ Feature: Find WordPress installs on the filesystem """ 1 """ + + Scenario: Directories with ignored path as substring should not be ignored + Given a WP install in 'wpblogs' + And a WP install in 'myjs' + And a WP install in 'logs' + And a WP install in 'js' + + When I run `wp eval --skip-wordpress 'echo realpath( getenv( "RUN_DIR" ) );'` + Then save STDOUT as {TEST_DIR} + + When I run `wp find {TEST_DIR} --field=version_path --verbose` + Then STDOUT should contain: + """ + Found WordPress installation at '{TEST_DIR}/wpblogs/wp-includes/version.php' + """ + And STDOUT should contain: + """ + Found WordPress installation at '{TEST_DIR}/myjs/wp-includes/version.php' + """ + And STDOUT should not contain: + """ + Found WordPress installation at '{TEST_DIR}/logs/wp-includes/version.php' + """ + And STDOUT should not contain: + """ + Found WordPress installation at '{TEST_DIR}/js/wp-includes/version.php' + """ + And STDOUT should contain: + """ + Matched ignored path. Skipping recursion into '{TEST_DIR}/logs/' + """ + And STDOUT should contain: + """ + Matched ignored path. Skipping recursion into '{TEST_DIR}/js/' + """ + + When I run `wp find {TEST_DIR} --format=count` + Then STDOUT should be: + """ + 2 + """ diff --git a/src/Find_Command.php b/src/Find_Command.php index f2a0fe5..e18aa87 100644 --- a/src/Find_Command.php +++ b/src/Find_Command.php @@ -244,7 +244,8 @@ private function recurse_directory( $path ) { return; } foreach ( $this->ignored_paths as $ignored_path ) { - if ( false !== stripos( $compared_path, $ignored_path ) ) { + // Match at directory boundaries: either at the start or after a directory separator + if ( 0 === stripos( $compared_path, $ignored_path ) || false !== stripos( $compared_path, '/' . $ignored_path ) ) { $this->log( "Matched ignored path. Skipping recursion into '{$path}'" ); return; } From f28365b72d9e3f72bbc038073c2e3294a020ab0c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 1 Nov 2025 20:34:49 +0000 Subject: [PATCH 3/3] Improve path matching with regex for better robustness Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/Find_Command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Find_Command.php b/src/Find_Command.php index e18aa87..02ef100 100644 --- a/src/Find_Command.php +++ b/src/Find_Command.php @@ -244,8 +244,8 @@ private function recurse_directory( $path ) { return; } foreach ( $this->ignored_paths as $ignored_path ) { - // Match at directory boundaries: either at the start or after a directory separator - if ( 0 === stripos( $compared_path, $ignored_path ) || false !== stripos( $compared_path, '/' . $ignored_path ) ) { + // Match at directory boundaries using regex to ensure we match complete directory names + if ( preg_match( '#(^|/)' . preg_quote( $ignored_path, '#' ) . '#i', $compared_path ) ) { $this->log( "Matched ignored path. Skipping recursion into '{$path}'" ); return; }