[wp-trac] [WordPress Trac] #39766: Plugin does not gracefully fail when editing active plugin causes fatal error

WordPress Trac noreply at wordpress.org
Mon Oct 2 13:12:49 UTC 2017


#39766: Plugin does not gracefully fail when editing active plugin causes fatal
error
-------------------------------------+-----------------------------
 Reporter:  ovann86                  |       Owner:  westonruter
     Type:  defect (bug)             |      Status:  reopened
 Priority:  high                     |   Milestone:  4.9
Component:  Plugins                  |     Version:  4.7.2
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  administration
-------------------------------------+-----------------------------

Comment (by jdgrimes):

 Replying to [comment:16 westonruter]:
 > @jdgrimes Just removing the `plugins_loaded` action fixes the issue for
 your own plugins?

 Yes.

 The reason that it was causing errors is because my plugin has some code
 hooked to `'plugins_loaded'` that alters an option in the database. That
 option also affects the behavior of the plugin's activation function.
 Basically, when that option is already set, the activation function
 assumes that the plugin has already been installed, and so it doesn't run
 some parts of the install routine (parts that it only needs to run on
 initial install and not on reactivation). As a result, those parts of the
 plugin are no longer activated by default.

 In short, the design of the activation function was based on the (up to
 now valid) assumption that no parts of the plugin code would be run prior
 to activation. Now you are running any code hooked to these actions prior
 to activation, and if the plugin has never been activated, prior to it
 running its install routine (assuming that it installs itself via the
 activation hook).

 Perhaps if you could determine whether the plugin had already been
 activated before or not, it would be OK to do something like this in
 `activate_plugin()` only in the case when the plugin was being
 ''reactivated''. Otherwise, I think that this is just asking for trouble.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39766#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list