[wp-trac] [WordPress Trac] #5860: In 2.5 bleeding, activating plugin that uses upgrade functions gives spurious warning

WordPress Trac wp-trac at lists.automattic.com
Thu Feb 14 19:20:39 GMT 2008


#5860: In 2.5 bleeding, activating plugin that uses upgrade functions gives
spurious warning
----------------------------+-----------------------------------------------
 Reporter:  jhodgdon        |       Owner:  anonymous
     Type:  defect          |      Status:  new      
 Priority:  normal          |   Milestone:  2.5      
Component:  Administration  |     Version:  2.5      
 Severity:  normal          |    Keywords:           
----------------------------+-----------------------------------------------
 Some plugins need to have their own database tables, and it's convenient
 for them to use the "dbDelta" function that is defined (currently) in wp-
 admin/includes/upgrade.php to maintain the tables (i.e. using the same
 method that the core of WordPress does to upgrade to new DB versions).

 So, a plugin might include the following line in its activate function, in
 order to include the file that contains that function:

 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');

 This worked fine through WordPress 2.3.x, but in 2.5 bleeding (tested in
 [6851]), including that file causes the following error to appear when you
 activate the plugin (I'll attach my very short test plugin as an
 attachment to the ticket):

 Plugin could not be activated because it triggered a fatal error.

 Fatal error: Cannot redeclare bugtest_test_activate() (previously declared
 in /opt/www/eclipsework/WPDev/wp-content/plugins/test.php:16) in
 /opt/www/eclipsework/WPDev/wp-content/plugins/test.php on line 17

 Contrary to the error message, the plugin is activated, however, and
 functions correctly after that point. The problem is apparently that it is
 being included twice, and the second time, of course, the functions are
 already there and cannot be redeclared.

 There needs to be a way for plugins to include the dbDelta function,
 without these activation errors. I'll investigate and propose a patch.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/5860>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list