[wp-trac] Re: [WordPress Trac] #7671: Plugin fatal error yields irrelevant error message from WordPress

WordPress Trac wp-trac at lists.automattic.com
Thu Sep 4 10:35:59 GMT 2008


#7671: Plugin fatal error yields irrelevant error message from WordPress
-------------------------------+--------------------------------------------
 Reporter:  omry               |        Owner:  anonymous
     Type:  defect             |       Status:  reopened 
 Priority:  normal             |    Milestone:  2.7      
Component:  General            |      Version:  2.7      
 Severity:  normal             |   Resolution:           
 Keywords:  reporter-feedback  |  
-------------------------------+--------------------------------------------
Comment (by DD32):

 >> it's better not to provide an error message at all than to provide some
 bogus irrelevant message.
 > No bogus error is produced, The "Bogus" error you provided was a PHP
 Fatal error message about you trying to redefine a allready defined
 function, Which is due to your code killing execution when its not
 expected to.

 Just a rephrase there:

 Its due to your plugin calling die() at a point AFTER which the fatal
 error protection is designed to protect.

 > Then plugin which deactivate themselves on activation if requirements
 are not met will be broken.
 Along with the plugins which use the activation hook to spawn off on a
 "Configure this plugin wizard"-type setup, Which i cant think of one off
 the top of my head, but feel there is one.


 > what I am really interested in is a way for a plugin to fail activation
 and to provide the user some error message.
 > naturally in such a case, the plugin should end up deactivated. how
 would I achieve something like this?

 {{{
 function bogus_activate(){
 deactivate_plugins(__FILE__);
 die('123');
 }
 }}}
 should work, once the attached patch is applied.

 Under 2.6 that example code would not work as expected, It'd trigger an
 error, but not show the error.

 In order to show the error, something like this would be used:
 {{{
 function bogus_activate(){
 deactivate_plugins(__FILE__);
 wp_die('123');
 }
 }}}

 I apologise for my point being all over the place in the comments here,
 I'm probably dead-tired :)

-- 
Ticket URL: <http://trac.wordpress.org/ticket/7671#comment:8>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list