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
|
| 2962 | 2962 | // Create a tablename index for an array ($cqueries) of recognized query types. |
| 2963 | 2963 | foreach ( $queries as $qry ) { |
| 2964 | 2964 | 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]; |
| 2967 | 2967 | continue; |
| 2968 | 2968 | } |
| 2969 | 2969 | |
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 {
|
| 1090 | 1090 | $updates |
| 1091 | 1091 | ); |
| 1092 | 1092 | } |
| | 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 | } |
| 1093 | 1115 | } |