wp-cli / extension-command

Manages plugins and themes, including installs, activations, and updates.
MIT License
90 stars 79 forks source link

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

Closed swissspidy closed 1 year ago

swissspidy commented 1 year ago

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' );

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

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).

raicem commented 1 year ago

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