[wp-trac] [WordPress Trac] #10404: dbDelta creates duplicate indexes when index definition contains spaces

WordPress Trac noreply at wordpress.org
Mon Mar 30 13:10:45 UTC 2020


#10404: dbDelta creates duplicate indexes when index definition contains spaces
-------------------------------+-----------------------
 Reporter:  Denis-de-Bernardy  |       Owner:  (none)
     Type:  enhancement        |      Status:  reopened
 Priority:  normal             |   Milestone:
Component:  Database           |     Version:  2.8.1
 Severity:  normal             |  Resolution:
 Keywords:  has-patch          |     Focuses:
-------------------------------+-----------------------
Changes (by arena):

 * status:  closed => reopened
 * resolution:  invalid =>


Comment:

 Sorry to be back on this ticket but i have the issue on wp trunk version
 (5.5-alpha-47528)

 this is a CREATE TABLE in schema.php

 {{{
 CREATE TABLE $wpdb->postmeta (
         meta_id bigint(20) unsigned NOT NULL auto_increment,
         post_id bigint(20) unsigned NOT NULL default '0',
         meta_key varchar(255) default NULL,
         meta_value longtext,
         PRIMARY KEY  (meta_id),
         KEY post_id (post_id),
         KEY meta_key (meta_key($max_index_length))
 ) $charset_collate;
 }}}



 This is my CREATE TABLE in a plugin


 {{{
 CREATE TABLE $wpdb->mp_mailmeta (
         meta_id bigint(20) unsigned NOT NULL auto_increment,
         mp_mail_id bigint(20) unsigned NOT NULL default '0',
         meta_key varchar(255) NOT NULL default '',
         meta_value longtext,
         PRIMARY KEY  (meta_id),
         KEY mp_mail_id (mp_mail_id),
         KEY meta_key (meta_key)
 ) $charset_collate;
 }}}


 On deactivation/activation of my plugin i have this :


 {{{
 The plugin generated xxx characters of unexpected output during
 activation. If you notice “headers already sent” messages, problems with
 syndication feeds or other issues, try deactivating or removing this
 plugin.
 }}}

 and in apache log


 {{{
 WordPress database error Duplicate key name 'mp_mail_id' for query ALTER
 TABLE wp_mailpress_mailmeta ADD KEY `mp_mail_id` (`mp_mail_id`) made by
 activate_plugin, do_action('activate_mailpress/MailPress.php'),
 WP_Hook->do_action, WP_Hook->apply_filters, MailPress::install,
 include('/plugins/mailpress/mp-admin/includes/install/mailpress.php'),
 dbDelta, referer: http://127.0.0.1/wordpress/wp-
 admin/plugins.php?plugin_status=all&paged=1&s
 }}}

 thank you for your help !

 Regards

 could be related to #34870 ?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/10404#comment:21>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list