Skip to content

Commit 2a4d8b3

Browse files
Copilotswissspidy
andcommitted
Fix --all --force interaction and remove duplicate test
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent deaf9c9 commit 2a4d8b3

File tree

2 files changed

+1
-37
lines changed

2 files changed

+1
-37
lines changed

features/plugin-install.feature

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -305,39 +305,3 @@ Feature: Install WordPress plugins
305305
"""
306306
active
307307
"""
308-
309-
Scenario: Force activate an already active plugin to re-run activation hooks
310-
Given a WP install
311-
And a wp-content/plugins/install-force-test/install-force-test.php file:
312-
"""
313-
<?php
314-
/**
315-
* Plugin Name: Install Force Test
316-
* Description: Test plugin for force install and activate
317-
* Version: 1.0.0
318-
* Author: WP-CLI tests
319-
*/
320-
321-
register_activation_hook( __FILE__, function() {
322-
@file_put_contents( WP_CONTENT_DIR . '/install-activation-test.txt', 'Activation hook was run' );
323-
});
324-
"""
325-
326-
When I run `wp plugin activate install-force-test`
327-
Then STDOUT should contain:
328-
"""
329-
Plugin 'install-force-test' activated.
330-
"""
331-
And the wp-content/install-activation-test.txt file should exist
332-
333-
# Remove the file to test if it gets recreated with --force
334-
When I run `rm wp-content/install-activation-test.txt`
335-
336-
# Now try activate --force (should re-run activation hooks)
337-
When I run `wp plugin activate install-force-test --force`
338-
Then STDOUT should contain:
339-
"""
340-
Plugin 'install-force-test' activated.
341-
"""
342-
And the return code should be 0
343-
And the wp-content/install-activation-test.txt file should exist

src/Plugin_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ public function activate( $args, $assoc_args = [] ) {
383383
}
384384
foreach ( $plugins as $plugin ) {
385385
$status = $this->get_status( $plugin->file );
386-
if ( $all && in_array( $status, [ 'active', 'active-network' ], true ) ) {
386+
if ( $all && ! $force && in_array( $status, [ 'active', 'active-network' ], true ) ) {
387387
continue;
388388
}
389389
// Network-active is the highest level of activation status.

0 commit comments

Comments
 (0)