Make WordPress Core

Opened 4 years ago

Last modified 4 years ago

#52405 new defect (bug)

activate_{$plugin} not passing $network_wide boolean to action handler

Reported by: noplanman's profile noplanman Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.0
Component: Plugins Keywords: has-patch needs-testing
Focuses: administration, multisite Cc:

Description

When using register_activation_hook, the "activate_{$plugin}" action doesn't pass the $network_wide boolean as the parameter for the callback.

Instead, the parameter gets substituted with an empty string, breaking the page when using strict typing, as it expects a boolean.

Looking at how it's done when activating plugins, it uses is_network_admin() as the parameter
https://core.trac.wordpress.org/browser/trunk/src/wp-admin/plugins.php?rev=49683#L124

Same thing should happen here:
https://core.trac.wordpress.org/browser/trunk/src/wp-admin/plugins.php?rev=49683#L193
do_action( "activate_{$plugin}", is_network_admin() );

Change History (4)

This ticket was mentioned in PR #961 on WordPress/wordpress-develop by noplanman.


4 years ago
#1

When using register_activation_hook, the "activate_{$plugin}" action doesn't pass the $network_wide boolean as the parameter for the callback.

Instead, the parameter gets substituted with an empty string, breaking the page when using strict typing, as it expects a boolean.

Looking at how it's done when activating plugins, it uses is_network_admin() as the parameter
https://github.com/WordPress/wordpress-develop/blob/6ef5edd41f8e6cdd5bc372fc02489f7bb423d8d1/src/wp-admin/plugins.php#L124

Same thing should happen here:
https://github.com/WordPress/wordpress-develop/blob/6ef5edd41f8e6cdd5bc372fc02489f7bb423d8d1/src/wp-admin/plugins.php#L193
do_action( "activate_{$plugin}", is_network_admin() );

Trac ticket: https://core.trac.wordpress.org/ticket/52405#ticket

#2 @SergeyBiryukov
4 years ago

Hi there, welcome to WordPress Trac! Thanks for the report.

Just linking to some related tickets here (of which this one might be a duplicate): #36406, #45779.

#3 @noplanman
4 years ago

Thanks for pointing those out @SergeyBiryukov, I searched various times but couldn't find anything 🤔

#4 @hellofromTonya
4 years ago

  • Version changed from trunk to 3.0
Note: See TracTickets for help on using tickets.