Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wp-admin/includes/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3201,7 +3201,7 @@ function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N
$fieldtype_base = strtok( $fieldtype_without_parentheses, ' ' );

// Is actual field type different from the field type in query?
if ( $tablefield->Type !== $fieldtype ) {
if ( $tablefield->Type !== $fieldtype_lowercased ) {
$do_change = true;
if ( in_array( $fieldtype_lowercased, $text_fields, true ) && in_array( $tablefield_type_lowercased, $text_fields, true ) ) {
if ( array_search( $fieldtype_lowercased, $text_fields, true ) < array_search( $tablefield_type_lowercased, $text_fields, true ) ) {
Expand Down
25 changes: 25 additions & 0 deletions tests/phpunit/tests/db/dbDelta.php
Original file line number Diff line number Diff line change
Expand Up @@ -1090,4 +1090,29 @@ public function test_column_type_change_with_hyphens_in_name() {
$updates
);
}

/**
* @ticket 59481
*/
public function test_column_types_are_not_case_sensitive() {
global $wpdb;

$updates = dbDelta(
"
CREATE TABLE {$wpdb->prefix}dbdelta_test (
id bigint(20) NOT NULL AUTO_INCREMENT,
column_1 varCHAr(255) NOT NULL,
column_2 TEXT,
column_3 blOB,
PRIMARY KEY (id),
KEY key_1 (column_1($this->max_index_length)),
KEY compound_key (id,column_1($this->max_index_length)),
FULLTEXT KEY fulltext_key (column_1)
) {$this->db_engine}
",
false
);

$this->assertEmpty( $updates );
}
}
Loading