Opened 11 months ago
Closed 11 months ago
#20995 closed defect (bug) (fixed)
[20525] breaks commonly used plugin technique for network activation
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.4.1 |
| Component: | Multisite | Version: | 3.4 |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: | ian_dunn@… |
Description
[20525] removed $_GET[ 'networkwide' ] during activation/de-activation, which is commonly used by plugins to hook into the process as described in a popular post by Shiba. This was discovered and documented by WPGetReady.
Instead of being immediately removed without warning, I think it should have followed the standard deprecation process so that developers can have time to update their plugins. $_GET[ 'networkwide' ] should be re-introduced in 3.4.1 in a deprecated fashion, and then completely removed in the future.
Change History (15)
comment:2
SergeyBiryukov — 11 months ago
- Milestone changed from Awaiting Review to 3.4.1
- Keywords close added
Example usage:
register_activation_hook( __FILE__, 'my_plugin_activation' );
function my_plugin_activation( $network_wide ) {
if ( $network_wide ) {
// it's a network activation
} else {
// it's a normal activation
}
}
- Keywords 2nd-opinion added
Thanks for pointing that out scribu, that looks like the best way to detect it going forward.
Where is that documented, though? How were plugin authors supposed to know about it? It isn't mentioned on the codex or the 3.4 field guide. I still think $_GET[ 'networkwide' ] should be reintroduced in 3.4.1 until plugin authors can be properly notified of the change and given time to update their code.
I guess it was not documented because there's still debate about how to handle network activation.
And, as is always the case when there's no clear way to do something, plugin authors have found workarounds, such as checking $_GET['networkwide'].
But, to answer your question about "how were plugin authors supposed to know", there was a notice (and a big discussion afterwards):
http://wpdevel.wordpress.com/2010/10/27/plugin-activation-hooks/
We want to point out some observations about this discussion:
Reading http://wpdevel.wordpress.com/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/ we interpreted no hook is reliable to detect updates.
We almost thought that activation hook was an ideal place to detect updates. We were wrong.
So, we followed the recommendation about the right way to do it. The current strategy rests over another hook(plugins_loaded) which supposedly it fires when the plugins are loaded, and also an option value to check if there were changes. This concept worked fine.
From the moment we knew updates couldn't trigger activation we also assumed there is no deactivation trigger . It is like the plugin passed through the updating process
without triggering hooks.
Trying to reuse the actual solution, we ended up parsing the url referrer to decide what to do. In this scenario $network_wide variable isn't useful, because we discarded the hooks.
What it would be the current recommendation? Thanks.
We probably should have kept $_GET['networkwide'] around in case plugins were using it.
For an activation, you can use the $network_wide argument that is passed to the activation hook. This replaces checking 'networkwide'.
For upgrades, I don't understand how networkwide would have ever helped you. Can you explain some more?
comment:10
WPReady — 11 months ago
We are not using that variable for any task related with upgrades.
comment:11
nacin — 11 months ago
We probably can do $_GET['networkwide'] = 1; in activate_plugins().
comment:12
nacin — 11 months ago
- Owner set to nacin
- Status changed from new to assigned
comment:13
nacin — 11 months ago
In [21104]:
comment:14
nacin — 11 months ago
- Keywords has-patch commit added; close 2nd-opinion removed
comment:15
nacin — 11 months ago
- Resolution set to fixed
- Status changed from assigned to closed
In [21130]:

https://www.google.com/search?q=site%3Aplugins.svn.wordpress.org+%22networkwide%22