Check if there is a comment_type index before adding one
Adding this check to avoid a MySQL error when running the query if the index already exists.
This commit is contained in:
parent
2e8f02f6a4
commit
7acf712e45
|
@ -404,9 +404,13 @@ class WC_Install {
|
||||||
|
|
||||||
dbDelta( self::get_schema() );
|
dbDelta( self::get_schema() );
|
||||||
|
|
||||||
// Add an index to the field comment_type to improve the response time of the query
|
$index_exists = $wpdb->get_row( "SHOW INDEX FROM {$wpdb->comments} WHERE Column_name = 'comment_type' and Key_name = 'comment_type'" );
|
||||||
// used by WC_Comments::wp_count_comments() to get the number of comments by type.
|
|
||||||
$wpdb->query( "ALTER TABLE {$wpdb->comments} ADD INDEX woo_idx_comment_type (comment_type)" );
|
if ( is_null( $index_exists ) ) {
|
||||||
|
// Add an index to the field comment_type to improve the response time of the query
|
||||||
|
// used by WC_Comments::wp_count_comments() to get the number of comments by type.
|
||||||
|
$wpdb->query( "ALTER TABLE {$wpdb->comments} ADD INDEX woo_idx_comment_type (comment_type)" );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue