wp-cli / extension-command

Manages plugins and themes, including installs, activations, and updates.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`activate/deactivate` command does not pass `$network_wide` as `bool`

swissspidy opened this issue · comments

Bug Report

Describe the current, buggy behavior

When calling wp plugin activate or wp plguin deactivate without explicitly pass --network, $network_wide will be null instead of false.

This causes errors if a plugin uses parameter types like this:

function myplugin_activate( bool $network_wide = false ): void {
	// ...
}

register_activation_hook( __FILE__, 'myplugin_activate' );

$network_wide = Utils\get_flag_value( $assoc_args, 'network' );

https://github.com/wp-cli/extension-command/blob/266d53d87f9c381677137cc79ed7805c9c0162a5/src/Plugin_Command.php#LL402C2-L402C2

Describe how other contributors can replicate this bug

Describe what you would expect as the correct outcome

No errors

Let us know what environment you are running this on

(Paste the output of "wp cli info" into this box)

Provide a possible solution

$network_wide should default to false so it's always a bool

Provide additional context/Screenshots

Add any other context about the problem here.

If applicable, add screenshots to help explain (you can just drag&drop images into the Github issue).

I'll look into this issue during the WCEU Contributor day 2023.