Skip to content

Commit 890b94b

Browse files
Copilotswissspidy
andcommitted
Revert to only scanning .php files and update test to pass version explicitly
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 40f9fbc commit 890b94b

2 files changed

Lines changed: 4 additions & 10 deletions

File tree

features/checksum-plugin.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Feature: Validate checksums for WordPress plugins
215215
When I run `mv wp-content/plugins/duplicate-post/duplicate-post.php wp-content/plugins/duplicate-post/duplicate-post.php.renamed`
216216
Then STDERR should be empty
217217

218-
When I try `wp plugin verify-checksums duplicate-post --format=json`
218+
When I try `wp plugin verify-checksums duplicate-post --version=3.2.1 --format=json`
219219
Then STDOUT should contain:
220220
"""
221221
"plugin_name":"duplicate-post","file":"duplicate-post.php.renamed","message":"File was added"

src/Checksum_Plugin_Command.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,8 @@ private function detect_version_from_directory( $plugin_dir ) {
253253
}
254254

255255
// Try scanning PHP files for Version header using WordPress's get_file_data()
256-
// Include both .php files and renamed .php.* files (e.g., .php.bak, .php.renamed)
257-
$php_files = glob( $plugin_path . '/*.php' );
258-
$renamed_files = glob( $plugin_path . '/*.php.*' );
259-
$files = array_merge(
260-
is_array( $php_files ) ? $php_files : array(),
261-
is_array( $renamed_files ) ? $renamed_files : array()
262-
);
263-
264-
if ( ! empty( $files ) ) {
256+
$files = glob( $plugin_path . '/*.php' );
257+
if ( is_array( $files ) && ! empty( $files ) ) {
265258
foreach ( $files as $file ) {
266259
if ( is_readable( $file ) ) {
267260
$file_data = get_file_data(
@@ -274,6 +267,7 @@ private function detect_version_from_directory( $plugin_dir ) {
274267
}
275268
}
276269
}
270+
// If glob() failed (returns false), version will just not be detected from PHP files
277271

278272
return false;
279273
}

0 commit comments

Comments
 (0)