[wp-trac] [WordPress Trac] #55329: add_clean_index function throws PHP notice error
WordPress Trac
noreply at wordpress.org
Mon Mar 7 13:59:36 UTC 2022
#55329: add_clean_index function throws PHP notice error
-----------------------------+-----------------------------
Reporter: gvgvgvijayan | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Upgrade/Install | Version:
Severity: normal | Keywords:
Focuses: administration |
-----------------------------+-----------------------------
When I tried to add index for newly created column my error log filled
with php notice 25 times because of the function `drop_index` which is
called inside the function `add_clean_index`.
Sample snippet:
{{{#!php
<?php
function add_country_iso_code_column() {
if ( ! function_exists( 'maybe_add_column' ) ) {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
}
global $wpdb;
$table_name = $wpdb->base_prefix . 'defender_lockout_log';
$column_name = 'country_iso_code';
$create_ddl = "ALTER TABLE {$table_name} ADD {$column_name}
CHAR(2) DEFAULT NULL";
maybe_add_column( $table_name, $column_name, $create_ddl );
add_clean_index( $table_name, $column_name );
}
}}}
Error:
{{{
[Mon Mar 07 18:45:40.809008 2022] [php:notice] [pid 1167] [client
127.0.0.1:48886] WordPress database error Can't DROP 'country_iso_code_1';
check that column/key exists for query ALTER TABLE
`wp_defender_lockout_log` DROP INDEX `country_iso_code_1` made by
require_once('wp-admin/network/admin.php'), require_once('wp-
admin/admin.php'), require_once('wp-load.php'), require_once('wp-
config.php'), require_once('wp-settings.php'), do_action('init'),
WP_Hook->do_action, WP_Hook->apply_filters, WP_Defender\\Upgrader->run,
WP_Defender\\Upgrader->upgrade_2_8_1,
WP_Defender\\Upgrader->add_country_iso_code_column, add_clean_index,
drop_index, referer: http://multi.test/wp-admin/network/update.php?action
=upload-plugin&package=55&overwrite=update-plugin&_wpnonce=c8b371f5b8
}}}
----
Error log screenshot:
[https://i.postimg.cc/2jqsb3Z4/bug-report.png]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55329>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list