Make WordPress Core

Ticket #63976: patch-63976.diff

File patch-63976.diff, 1.6 KB (added by leewillis77, 14 months ago)
  • src/wp-admin/includes/upgrade.php

    diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php
    index e206152e84..26b8c97359 100644
    a b function dbDelta( $queries = '', $execute = true ) { // phpcs:ignore WordPress.N  
    29622962        // Create a tablename index for an array ($cqueries) of recognized query types.
    29632963        foreach ( $queries as $qry ) {
    29642964                if ( preg_match( '|CREATE TABLE ([^ ]*)|', $qry, $matches ) ) {
    2965                         $cqueries[ trim( $matches[1], '`' ) ] = $qry;
    2966                         $for_update[ $matches[1] ]            = 'Created table ' . $matches[1];
     2965                        $cqueries[ trim( $matches[1], '`' ) ]   = $qry;
     2966                        $for_update[ trim( $matches[1], '`' ) ] = 'Created table ' . $matches[1];
    29672967                        continue;
    29682968                }
    29692969
  • tests/phpunit/tests/db/dbDelta.php

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