Ticket #6747 (new defect)

Opened 3 months ago

Last modified 1 month ago

function maybe_create_table() declared in two files

Reported by: mastermind Assigned to: anonymous
Priority: low Milestone: 2.7
Component: General Version: 2.5
Severity: blocker Keywords: has-patch
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

upgrade.diff (2.0 kB) - added by solsen230 on 05/31/08 17:45:32.
wp-admin/include/upgrade.php

Change History

05/31/08 17:45:32 changed by solsen230

  • attachment upgrade.diff added.

wp-admin/include/upgrade.php

05/31/08 17:49:44 changed by solsen230

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.

05/31/08 17:53:10 changed by solsen230

  • keywords set to has_patch.

05/31/08 17:57:52 changed by solsen230

  • keywords changed from has_patch to has-patch.