Skip to content

Commit 5c7fbd9

Browse files
authored
Merge pull request #143 from austinginder/fix-90-plugin-update-reporting
🐛 FIX: Failed plugin updates not throwing errors
2 parents 8e0412d + f313ddf commit 5c7fbd9

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

features/plugin-update.feature

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,20 @@ Feature: Update WordPress plugins
191191
"""
192192
Error: Can't find the requested plugin's version 2.5.4 in the WordPress.org plugin repository (HTTP code 404).
193193
"""
194+
195+
@require-wp-4.7
196+
Scenario: Plugin updates that error should not report a success
197+
Given a WP install
198+
And I run `wp plugin install --force akismet --version=4.0`
199+
And I run `chmod -w wp-content/plugins/akismet`
200+
And I try `wp plugin update akismet`
201+
And save STDERR as {ERROR}
202+
And I run `chmod +w wp-content/plugins/akismet`
203+
204+
And I run `echo "{ERROR}"`
205+
Then STDOUT should contain:
206+
"""
207+
Error:
208+
"""
209+
210+

features/plugin.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ Feature: Manage WordPress plugins
500500
"""
501501
And the return code should be 0
502502

503+
@require-wp-47
503504
Scenario: Plugin hidden by "all_plugins" filter
504505
Given a WP install
505506
And these installed and active plugins:

src/WP_CLI/CommandWithUpgrade.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,9 @@ protected function update_many( $args, $assoc_args ) {
401401
'new_version' => $info['update_version'],
402402
'status' => $result[ $info['update_id'] ] !== null ? 'Updated' : 'Error',
403403
);
404+
if ( null === $result[ $info['update_id'] ] ) {
405+
$errors++;
406+
}
404407
}
405408

406409
$format = 'table';

0 commit comments

Comments
 (0)