Make WordPress Core

Ticket #59481: 59481-3.diff

File 59481-3.diff, 1.7 KB (added by leewillis77, 4 months ago)

Updated patch to add unit test

  • src/wp-admin/includes/upgrade.php

    diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php
    index e206152e84..6e79e45477 100644
    a b function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N 
    32013201                                $fieldtype_base = strtok( $fieldtype_without_parentheses, ' ' );
    32023202
    32033203                                // Is actual field type different from the field type in query?
    3204                                 if ( $tablefield->Type !== $fieldtype ) {
     3204                                if ( $tablefield->Type !== $fieldtype_lowercased ) {
    32053205                                        $do_change = true;
    32063206                                        if ( in_array( $fieldtype_lowercased, $text_fields, true ) && in_array( $tablefield_type_lowercased, $text_fields, true ) ) {
    32073207                                                if ( array_search( $fieldtype_lowercased, $text_fields, true ) < array_search( $tablefield_type_lowercased, $text_fields, true ) ) {
  • tests/phpunit/tests/db/dbDelta.php

    diff --git a/tests/phpunit/tests/db/dbDelta.php b/tests/phpunit/tests/db/dbDelta.php
    index 8b028e030e..5436d9fe1a 100644
    a b class Tests_DB_dbDelta extends WP_UnitTestCase { 
    10901090                        $updates
    10911091                );
    10921092        }
     1093
     1094        /**
     1095         * @ticket 59481
     1096         */
     1097        public function test_column_types_are_not_case_sensitive() {
     1098                global $wpdb;
     1099
     1100                $updates = dbDelta(
     1101                        "
     1102                        CREATE TABLE {$wpdb->prefix}dbdelta_test (
     1103                                id bigint(20) NOT NULL AUTO_INCREMENT,
     1104                                column_1 varCHAr(255) NOT NULL,
     1105                                column_2 TEXT,
     1106                                column_3 blOB,
     1107                                PRIMARY KEY  (id),
     1108                                KEY key_1 (column_1($this->max_index_length)),
     1109                                KEY compound_key (id,column_1($this->max_index_length)),
     1110                                FULLTEXT KEY fulltext_key (column_1)
     1111                        ) {$this->db_engine}
     1112                        ",
     1113                        false
     1114                );
     1115
     1116                $this->assertEmpty( $updates );
     1117        }
    10931118}