Opened 17 years ago
Closed 17 years ago
#6747 closed defect (bug) (fixed)
function maybe_create_table() declared in two files
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.6.1 | Priority: | low |
Severity: | blocker | Version: | 2.6 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
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.
Attachments (1)
Change History (8)
#1
@
17 years ago
I uploaded a patch that should fix this. Untested.
Changes - Removed maybe_create_table() and maybe_add_column() functions in the upgrade.php file referenced in ticket. require_once'd install-helper.php to make these functions still available to upgrade.php.
#4
@
17 years ago
- Version changed from 2.5 to 2.6
Don't think install-helper.php was meant to be used by plugins that need to create tables. There's dbDelta() defined in upgrade.php for this. Still, wrapping these functions in !function_exists() just in case.
wp-admin/include/upgrade.php