[wp-trac] [WordPress Trac] #6747: function maybe_create_table()
declared in two files
WordPress Trac
wp-trac at lists.automattic.com
Wed Apr 16 14:27:41 GMT 2008
#6747: function maybe_create_table() declared in two files
------------------------+---------------------------------------------------
Reporter: mastermind | Owner: anonymous
Type: defect | Status: new
Priority: low | Milestone: 2.7
Component: General | Version: 2.5
Severity: blocker | Keywords:
------------------------+---------------------------------------------------
The function {{{maybe_create_table()}}} is a nice helper for plugins that
need to create a database table. As it is not available by default, one
has to include the file which contains this function. So far so good.
However, {{{maybe_create_table()}}} is declared in {{{/wp-admin/install-
helper.php}}} as well as in {{{/wp-admin/includes/upgrade.php}}}.
If, as a matter of coincidence, both of the above files are loaded, then
this will of course throw a "''Fatal error: Cannot redeclare
maybe_create_table() in /var/www/htdocs/elnl.zirona.de/wp-
admin/includes/upgrade.php on line 735''"
This is not only theoretical, but I actually encountered this in the
following situation:
A plugin of mine uses a function {{{activate_plugin()}}}, called via
{{{register_activation_hook(__FILE__, 'activate_plugin');}}}. That
function loads {{{/wp-admin/install-helper.php}}} to use the function
{{{maybe_create_table()}}}. When I tried to import content to the blog
(Manage -> Import -> WordPress), the page would die with the Fatal error.
The solution was to temporarily deactivate the table creating routine from
the activation function.
--
Ticket URL: <http://trac.wordpress.org/ticket/6747>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list