Skip to content

Commit bc1752a

Browse files
committed
some fixes
1 parent f2d0e80 commit bc1752a

2 files changed

Lines changed: 23 additions & 27 deletions

File tree

features/checksum-plugin.feature

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ Feature: Validate checksums for WordPress plugins
167167
"""
168168

169169
When I try `wp plugin verify-checksums --all --exclude=akismet`
170-
Then STDOUT should match /^Success: Verified 0 of \d plugins \(\d skipped\)\.$/
170+
Then STDOUT should match /^Success: Verified \d of \d plugins \(\d skipped\)\./
171171

172172
Scenario: Plugin is verified when the --exclude argument isn't included
173173
Given a WP install
@@ -186,7 +186,7 @@ Feature: Validate checksums for WordPress plugins
186186
"""
187187

188188
When I try `wp plugin verify-checksums --all`
189-
Then STDOUT should match /^Success: Verified 1 of \d plugins/
189+
Then STDOUT should match /^Success: Verified \d of \d plugins/
190190

191191
# Hello Dolly was moved from a single file to a directory in WordPress 6.9
192192
@less-than-wp-6.9
@@ -210,8 +210,12 @@ Feature: Validate checksums for WordPress plugins
210210
When I run `mv wp-content/plugins/duplicate-post wp-content/mu-plugins/`
211211
Then STDERR should be empty
212212

213-
When I run `wp plugin verify-checksums --all`
214-
Then STDOUT should match /^Success: Verified 1 of \d plugins/
213+
When I try `wp plugin verify-checksums --all`
214+
Then STDOUT should match /Success: Verified \d of \d plugins/
215+
And STDERR should not contain:
216+
"""
217+
duplicate-post
218+
"""
215219

216220
Scenario: Exclude must-use plugins from verification
217221
Given a WP install
@@ -246,10 +250,7 @@ Feature: Validate checksums for WordPress plugins
246250
"""
247251
"plugin_name":"duplicate-post","file":"duplicate-post.php","message":"Checksum does not match"
248252
"""
249-
And STDERR should contain:
250-
"""
251-
Error: No plugins verified (1 failed).
252-
"""
253+
And STDERR should match /Error: Only verified \d of \d plugins/
253254

254255
Scenario: Single-file must-use plugin without checksums shows warning
255256
Given a WP install
@@ -267,4 +268,4 @@ Feature: Validate checksums for WordPress plugins
267268
"""
268269
Warning: Must-use plugin 'custom-mu-plugin.php' appears to be a custom file or loader plugin and cannot be verified.
269270
"""
270-
And STDOUT should match /Success: Verified 2 of \d plugins \(\d skipped\)\.$/
271+
And STDOUT should match /Success: Verified \d of \d plugins \(\d skipped\)\./

src/Checksum_Plugin_Command.php

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function __invoke( $args, $assoc_args ) {
8383
$insecure = Utils\get_flag_value( $assoc_args, 'insecure', false );
8484
$exclude_mu = Utils\get_flag_value( $assoc_args, 'exclude-mu-plugins', false );
8585
$plugins = $fetcher->get_many( $all ? $this->get_all_plugin_names() : $args );
86+
$mu_plugins = ! $exclude_mu ? array_merge( get_mu_plugins(), get_plugins( '/../' . basename( WPMU_PLUGIN_DIR ) ) ) : [];
8687

8788
/**
8889
* @var string $exclude
@@ -155,29 +156,23 @@ public function __invoke( $args, $assoc_args ) {
155156

156157
$total = count( $plugins );
157158

158-
// Process must-use plugins if not excluded.
159-
$mu_plugins = array();
160-
if ( ! $exclude_mu ) {
161-
$mu_plugins = get_plugins( '/../mu-plugins' );
159+
foreach ( $mu_plugins as $mu_file => $mu_plugin ) {
160+
$plugin_name = $this->get_plugin_slug_from_path( $mu_file );
162161

163-
foreach ( $mu_plugins as $mu_file => $mu_plugin ) {
164-
$plugin_name = $this->get_plugin_slug_from_path( $mu_file );
165-
166-
if ( ! empty( $args ) ) {
167-
if ( ! in_array( $plugin_name, $args, true ) ) {
168-
continue;
169-
} else {
170-
++$total;
171-
}
172-
}
173-
174-
if ( in_array( $plugin_name, $exclude_list, true ) ) {
175-
++$skips;
162+
if ( ! empty( $args ) ) {
163+
if ( ! in_array( $plugin_name, $args, true ) ) {
176164
continue;
165+
} else {
166+
++$total;
177167
}
168+
}
178169

179-
$this->verify_mu_plugin( $mu_file, $mu_plugin, $plugin_name, $version_arg, $insecure, $strict, $skips );
170+
if ( in_array( $plugin_name, $exclude_list, true ) ) {
171+
++$skips;
172+
continue;
180173
}
174+
175+
$this->verify_mu_plugin( $mu_file, $mu_plugin, $plugin_name, $version_arg, $insecure, $strict, $skips );
181176
}
182177

183178
if ( ! empty( $this->errors ) ) {

0 commit comments

Comments
 (0)