[wp-trac] Re: [WordPress Trac] #6308: Edit Plugins screen issue

WordPress Trac wp-trac at lists.automattic.com
Thu Mar 20 19:21:13 GMT 2008


#6308: Edit Plugins screen issue
-------------------------------+--------------------------------------------
 Reporter:  Denis-de-Bernardy  |        Owner:  neodude 
     Type:  task               |       Status:  assigned
 Priority:  low                |    Milestone:          
Component:  Administration     |      Version:  2.5     
 Severity:  minor              |   Resolution:          
 Keywords:  dev-feedback       |  
-------------------------------+--------------------------------------------
Changes (by Denis-de-Bernardy):

  * keywords:  has-patch => dev-feedback
  * priority:  normal => low
  * type:  defect => task
  * severity:  major => minor
  * milestone:  2.5 =>

Comment:

 Imho, scanning through the entire list of plugins on every page of the
 admin area is a rather bad idea. At most, it should be done when we're
 browsing the plugins menu.

 Btw, further investigation revealed it was actually one of my plugins that
 was causing the error. I had a loop like this in a plugin file:

 foreach ( array('file.php') as file )
 include $path . $file;

 Upon deactivating it, I could access the plugin editor page again.

 This prompts me to a thought, however. My understanding was that, in WP
 2.5, plugin files now needed to explicitly declare variables in the global
 scope. So I felt rather save to use the $file variable... Reading through
 the wp-settings.php file reveals they aren't.

 Anyway, I can see all sorts of false alarms like this one happening
 because of this because of plugins overwriting global variables without
 giving thoughts to how WP might be using them later on. And I'd strongly
 suggest to give that idea a thought once again if it has been dropped.

 The fix is rather simple. Simply change:


 {{{
 if ( get_option('active_plugins') ) {
         $current_plugins = get_option('active_plugins');
         if ( is_array($current_plugins) ) {
                 foreach ($current_plugins as $plugin) {
                         if ('' != $plugin && file_exists(ABSPATH .
 PLUGINDIR . '/' . $plugin))
                                 include_once(ABSPATH . PLUGINDIR . '/' .
 $plugin);
                 }
         }
 }

 }}}


 To:


 {{{
 if ( $current_plugins = get_option('active_plugins') &&
 is_array($current_plugins ) {
         function wp_include_plugin($plugin) {
                 if ('' != $plugin && file_exists(ABSPATH . PLUGINDIR . '/'
 . $plugin))
                         include_once(ABSPATH . PLUGINDIR . '/' . $plugin);
         }

         foreach ($current_plugins as $plugin) {
                 wp_include_plugin($plugin);
         }
 }
 }}}

 It mostly goes down to weighing the costs of breaking a few plugins vs the
 costs of seeing an invalid bug every now and then.

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


More information about the wp-trac mailing list