[wp-trac] [WordPress Trac] #31104: Plugin activation includes plugin file in variable scope of activate_plugin

WordPress Trac noreply at wordpress.org
Wed Apr 14 23:03:01 UTC 2021

#31104: Plugin activation includes plugin file in variable scope of activate_plugin
 Reporter:  Mike_Cowobo      |       Owner:  SergeyBiryukov
     Type:  defect (bug)     |      Status:  reviewing
 Priority:  normal           |   Milestone:  5.8
Component:  Plugins          |     Version:  4.2
 Severity:  normal           |  Resolution:
 Keywords:  has-patch early  |     Focuses:
Changes (by SergeyBiryukov):

 * owner:  dd32 => SergeyBiryukov
 * milestone:  Future Release => 5.8


 Replying to [comment:6 dd32]:
 > The patch as-is, can't be applied, as it's got back-compat concerns.
 > Those concerns are that it no longer has access to the same variables
 that it previously did, so something like this would be needed (although I
 dislike the usage of extract, which we're trying to avoid).

 Here's the list of the variables in question, for reference:

 `$plugin, $redirect, $network_wide, $silent, $current, $valid,

 I think `$valid` and `$requirements` can be discarded right away, these
 are one-time internal variables.

 I thought of passing something like this as a second argument to

 `$args = compact( 'plugin', 'redirect', 'network_wide', 'silent',
 'current' );`

 And then recreating them there, to avoid using `extract()` as per #22400:
 $plugin       = $args['plugin'];
 $redirect     = $args['redirect'];
 $network_wide = $args['network_wide'];
 $silent       = $args['silent'];
 $current      = $args['current'];

 However, it looks like most of these are also internal variables that a
 plugin should not really be concerned with, except for maybe
 `$network_wide`. As noted above, running any code depending on these
 values directly at inclusion time is bad practice that we may not
 necessarily want to support. As a workaround for `$network_wide`, plugins
 still have access to `$_GET['networkwide']`, see [21104] / #20995.

 So it seems like we can try [attachment:"31104.diff"] early in 5.8 and see
 what plugins break, if any, and then decide if any of these variables are
 necessary to keep for backward compatibility.

Ticket URL: <https://core.trac.wordpress.org/ticket/31104#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list