From 6f5a36b29f9b59f92499ca75b1b6557468a2661b Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Thu, 12 Dec 2024 11:19:12 +0100 Subject: [PATCH 01/13] Add test that shows incorrect behavior --- tests/WP_SQLite_Translator_Tests.php | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/WP_SQLite_Translator_Tests.php b/tests/WP_SQLite_Translator_Tests.php index b93afe30..6da90603 100644 --- a/tests/WP_SQLite_Translator_Tests.php +++ b/tests/WP_SQLite_Translator_Tests.php @@ -462,6 +462,37 @@ public function testShowCreateTablePreservesDoubleUnderscoreKeyNames() { ); } + public function testShowCreateTableLimitsKeyLengths() { + $this->assertQuery( + "CREATE TABLE _tmp__table ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `order_id` bigint(20) unsigned DEFAULT NULL, + `meta_key` varchar(255) DEFAULT NULL, + `meta_value` text DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `meta_key_value` (`meta_key`(100),`meta_value`(82)), + KEY `order_id_meta_key_meta_value` (`order_id`,`meta_key`(100),`meta_value`(82)) + );" + ); + + $this->assertQuery( + 'SHOW CREATE TABLE _tmp__table;' + ); + $results = $this->engine->get_query_results(); + $this->assertEquals( + 'CREATE TABLE `_tmp__table` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `order_id` bigint(20) unsigned DEFAULT NULL, + `meta_key` varchar(255) DEFAULT NULL, + `meta_value` text DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `order_id_meta_key_meta_value` (`order_id`,`meta_key`(100),`meta_value`(82)), + KEY `meta_key_value` (`meta_key`(100),`meta_value`(82)) +);', + $results[0]->{'Create Table'} + ); + } + public function testShowCreateTableWithPrimaryKeyColumnsReverseOrdered() { $this->assertQuery( 'CREATE TABLE `_tmp_table` ( From e81395677c9383f607a623b6a610416329662471 Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Thu, 12 Dec 2024 17:24:21 +0100 Subject: [PATCH 02/13] Set varchar and text key field limits --- wp-includes/sqlite/class-wp-sqlite-translator.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/sqlite/class-wp-sqlite-translator.php b/wp-includes/sqlite/class-wp-sqlite-translator.php index 0f61a7c7..9e41e832 100644 --- a/wp-includes/sqlite/class-wp-sqlite-translator.php +++ b/wp-includes/sqlite/class-wp-sqlite-translator.php @@ -3725,6 +3725,7 @@ protected function get_column_definitions( $table_name, $columns ) { * @return array An array of key definitions */ private function get_key_definitions( $table_name, $columns ) { + $key_length_limit = 100; $key_definitions = array(); $pks = array(); @@ -3756,7 +3757,11 @@ private function get_key_definitions( $table_name, $columns ) { $key_definition[] = sprintf( '`%s`', $index_name ); $cols = array_map( - function ( $column ) { + function ( $column ) use ( $table_name, $key_length_limit ) { + $data_type = strtolower( $this->get_cached_mysql_data_type( $table_name, $column['name'] ) ); + if ( 'text' === $data_type || str_starts_with( $data_type, 'varchar' ) ) { + return sprintf( '`%s`(%s)', $column['name'], $key_length_limit ); + } return sprintf( '`%s`', $column['name'] ); }, $key['columns'] From 2b30f2513ae3e69a9050fee299031d1e92570b7c Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Thu, 12 Dec 2024 17:24:57 +0100 Subject: [PATCH 03/13] Update tests to account for key limits --- tests/WP_SQLite_Translator_Tests.php | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/WP_SQLite_Translator_Tests.php b/tests/WP_SQLite_Translator_Tests.php index 6da90603..3b386254 100644 --- a/tests/WP_SQLite_Translator_Tests.php +++ b/tests/WP_SQLite_Translator_Tests.php @@ -267,8 +267,8 @@ public function testShowCreateTable1() { ID BIGINT PRIMARY KEY AUTO_INCREMENT NOT NULL, option_name VARCHAR(255) default '', option_value TEXT NOT NULL, - UNIQUE KEY option_name (option_name), - KEY composite (option_name, option_value) + UNIQUE KEY option_name (option_name(100)), + KEY composite (option_name(100), option_value(100)) );" ); @@ -283,8 +283,8 @@ public function testShowCreateTable1() { `option_name` varchar(255) DEFAULT '', `option_value` text NOT NULL DEFAULT '', PRIMARY KEY (`ID`), - KEY `composite` (`option_name`, `option_value`), - UNIQUE KEY `option_name` (`option_name`) + KEY `composite` (`option_name`(100), `option_value`(100)), + UNIQUE KEY `option_name` (`option_name`(100)) );", $results[0]->{'Create Table'} ); @@ -337,8 +337,8 @@ public function testShowCreateTableQuoted() { ID BIGINT PRIMARY KEY AUTO_INCREMENT NOT NULL, option_name VARCHAR(255) default '', option_value TEXT NOT NULL, - UNIQUE KEY option_name (option_name), - KEY composite (option_name, option_value) + UNIQUE KEY option_name (option_name(100)), + KEY composite (option_name, option_value(100)) );" ); @@ -353,8 +353,8 @@ public function testShowCreateTableQuoted() { `option_name` varchar(255) DEFAULT '', `option_value` text NOT NULL DEFAULT '', PRIMARY KEY (`ID`), - KEY `composite` (`option_name`, `option_value`), - UNIQUE KEY `option_name` (`option_name`) + KEY `composite` (`option_name`(100), `option_value`(100)), + UNIQUE KEY `option_name` (`option_name`(100)) );", $results[0]->{'Create Table'} ); @@ -418,8 +418,8 @@ public function testCreateTablseWithIdenticalIndexNames() { ID BIGINT PRIMARY KEY AUTO_INCREMENT NOT NULL, option_name VARCHAR(255) default '', option_value TEXT NOT NULL, - KEY `option_name` (`option_name`), - KEY `double__underscores` (`option_name`, `ID`) + KEY `option_name` (`option_name`(100)), + KEY `double__underscores` (`option_name`(100), `ID`) );" ); @@ -428,8 +428,8 @@ public function testCreateTablseWithIdenticalIndexNames() { ID BIGINT PRIMARY KEY AUTO_INCREMENT NOT NULL, option_name VARCHAR(255) default '', option_value TEXT NOT NULL, - KEY `option_name` (`option_name`), - KEY `double__underscores` (`option_name`, `ID`) + KEY `option_name` (`option_name`(100)), + KEY `double__underscores` (`option_name`(100), `ID`) );" ); } @@ -440,8 +440,8 @@ public function testShowCreateTablePreservesDoubleUnderscoreKeyNames() { ID BIGINT PRIMARY KEY AUTO_INCREMENT NOT NULL, option_name VARCHAR(255) default '', option_value TEXT NOT NULL, - KEY `option_name` (`option_name`), - KEY `double__underscores` (`option_name`, `ID`) + KEY `option_name` (`option_name`(100)), + KEY `double__underscores` (`option_name`(100), `ID`) );" ); @@ -455,8 +455,8 @@ public function testShowCreateTablePreservesDoubleUnderscoreKeyNames() { `option_name` varchar(255) DEFAULT \'\', `option_value` text NOT NULL DEFAULT \'\', PRIMARY KEY (`ID`), - KEY `double__underscores` (`option_name`, `ID`), - KEY `option_name` (`option_name`) + KEY `double__underscores` (`option_name`(100), `ID`), + KEY `option_name` (`option_name`(100)) );', $results[0]->{'Create Table'} ); @@ -486,8 +486,8 @@ public function testShowCreateTableLimitsKeyLengths() { `meta_key` varchar(255) DEFAULT NULL, `meta_value` text DEFAULT NULL, PRIMARY KEY (`id`), - KEY `order_id_meta_key_meta_value` (`order_id`,`meta_key`(100),`meta_value`(82)), - KEY `meta_key_value` (`meta_key`(100),`meta_value`(82)) + KEY `order_id_meta_key_meta_value` (`order_id`, `meta_key`(100), `meta_value`(100)), + KEY `meta_key_value` (`meta_key`(100), `meta_value`(100)) );', $results[0]->{'Create Table'} ); From 993bb3919daf822832cc81f8ecb503ab41c1ad02 Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Thu, 12 Dec 2024 17:29:41 +0100 Subject: [PATCH 04/13] Fix lint issue --- tests/WP_SQLite_Translator_Tests.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/WP_SQLite_Translator_Tests.php b/tests/WP_SQLite_Translator_Tests.php index 3b386254..50f077be 100644 --- a/tests/WP_SQLite_Translator_Tests.php +++ b/tests/WP_SQLite_Translator_Tests.php @@ -464,7 +464,7 @@ public function testShowCreateTablePreservesDoubleUnderscoreKeyNames() { public function testShowCreateTableLimitsKeyLengths() { $this->assertQuery( - "CREATE TABLE _tmp__table ( + 'CREATE TABLE _tmp__table ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `order_id` bigint(20) unsigned DEFAULT NULL, `meta_key` varchar(255) DEFAULT NULL, @@ -472,7 +472,7 @@ public function testShowCreateTableLimitsKeyLengths() { PRIMARY KEY (`id`), KEY `meta_key_value` (`meta_key`(100),`meta_value`(82)), KEY `order_id_meta_key_meta_value` (`order_id`,`meta_key`(100),`meta_value`(82)) - );" + );' ); $this->assertQuery( From 652c2527eb13a0764390d9ee233a05a3ab325e78 Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Thu, 12 Dec 2024 18:25:48 +0100 Subject: [PATCH 05/13] Fix another lint issue --- wp-includes/sqlite/class-wp-sqlite-translator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-includes/sqlite/class-wp-sqlite-translator.php b/wp-includes/sqlite/class-wp-sqlite-translator.php index 9e41e832..dac3adab 100644 --- a/wp-includes/sqlite/class-wp-sqlite-translator.php +++ b/wp-includes/sqlite/class-wp-sqlite-translator.php @@ -3726,7 +3726,7 @@ protected function get_column_definitions( $table_name, $columns ) { */ private function get_key_definitions( $table_name, $columns ) { $key_length_limit = 100; - $key_definitions = array(); + $key_definitions = array(); $pks = array(); foreach ( $columns as $column ) { From 211826fc1efbe60406a31a29cd4257c6201719b7 Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Fri, 13 Dec 2024 11:27:45 +0100 Subject: [PATCH 06/13] Ensure that key length is not higher than field length --- tests/WP_SQLite_Translator_Tests.php | 10 +++++----- wp-includes/sqlite/class-wp-sqlite-translator.php | 11 ++++++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/WP_SQLite_Translator_Tests.php b/tests/WP_SQLite_Translator_Tests.php index 50f077be..fdfb486c 100644 --- a/tests/WP_SQLite_Translator_Tests.php +++ b/tests/WP_SQLite_Translator_Tests.php @@ -467,10 +467,10 @@ public function testShowCreateTableLimitsKeyLengths() { 'CREATE TABLE _tmp__table ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `order_id` bigint(20) unsigned DEFAULT NULL, - `meta_key` varchar(255) DEFAULT NULL, + `meta_key` varchar(20) DEFAULT NULL, `meta_value` text DEFAULT NULL, PRIMARY KEY (`id`), - KEY `meta_key_value` (`meta_key`(100),`meta_value`(82)), + KEY `meta_key_value` (`meta_key`(20),`meta_value`(82)), KEY `order_id_meta_key_meta_value` (`order_id`,`meta_key`(100),`meta_value`(82)) );' ); @@ -483,11 +483,11 @@ public function testShowCreateTableLimitsKeyLengths() { 'CREATE TABLE `_tmp__table` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `order_id` bigint(20) unsigned DEFAULT NULL, - `meta_key` varchar(255) DEFAULT NULL, + `meta_key` varchar(20) DEFAULT NULL, `meta_value` text DEFAULT NULL, PRIMARY KEY (`id`), - KEY `order_id_meta_key_meta_value` (`order_id`, `meta_key`(100), `meta_value`(100)), - KEY `meta_key_value` (`meta_key`(100), `meta_value`(100)) + KEY `order_id_meta_key_meta_value` (`order_id`, `meta_key`(20), `meta_value`(100)), + KEY `meta_key_value` (`meta_key`(20), `meta_value`(100)) );', $results[0]->{'Create Table'} ); diff --git a/wp-includes/sqlite/class-wp-sqlite-translator.php b/wp-includes/sqlite/class-wp-sqlite-translator.php index dac3adab..be8c9317 100644 --- a/wp-includes/sqlite/class-wp-sqlite-translator.php +++ b/wp-includes/sqlite/class-wp-sqlite-translator.php @@ -3759,8 +3759,17 @@ private function get_key_definitions( $table_name, $columns ) { $cols = array_map( function ( $column ) use ( $table_name, $key_length_limit ) { $data_type = strtolower( $this->get_cached_mysql_data_type( $table_name, $column['name'] ) ); + $data_length = $key_length_limit; + + // Extract the length from the data type. Make it lower if needed. + if ( 1 === preg_match( '/^(\w+)\((\d+)\)$/', $data_type, $matches ) ) { + $data_type = $matches[1]; // "varchar" + $data_length = min( $matches[2], $key_length_limit ); // "255" + } + + // Set the data length to the varchar and text key length if ( 'text' === $data_type || str_starts_with( $data_type, 'varchar' ) ) { - return sprintf( '`%s`(%s)', $column['name'], $key_length_limit ); + return sprintf( '`%s`(%s)', $column['name'], $data_length ); } return sprintf( '`%s`', $column['name'] ); }, From b2794e60c414851aad2c2833c82ab44f3d3ddef5 Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Fri, 13 Dec 2024 11:29:19 +0100 Subject: [PATCH 07/13] Fix lint issues --- wp-includes/sqlite/class-wp-sqlite-translator.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/sqlite/class-wp-sqlite-translator.php b/wp-includes/sqlite/class-wp-sqlite-translator.php index be8c9317..519abc2d 100644 --- a/wp-includes/sqlite/class-wp-sqlite-translator.php +++ b/wp-includes/sqlite/class-wp-sqlite-translator.php @@ -3758,12 +3758,12 @@ private function get_key_definitions( $table_name, $columns ) { $cols = array_map( function ( $column ) use ( $table_name, $key_length_limit ) { - $data_type = strtolower( $this->get_cached_mysql_data_type( $table_name, $column['name'] ) ); + $data_type = strtolower( $this->get_cached_mysql_data_type( $table_name, $column['name'] ) ); $data_length = $key_length_limit; // Extract the length from the data type. Make it lower if needed. if ( 1 === preg_match( '/^(\w+)\((\d+)\)$/', $data_type, $matches ) ) { - $data_type = $matches[1]; // "varchar" + $data_type = $matches[1]; // "varchar" $data_length = min( $matches[2], $key_length_limit ); // "255" } From e23b96764cb990a69037bd6e7630219a9de9591b Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Thu, 19 Dec 2024 18:55:06 +0100 Subject: [PATCH 08/13] Add tests for blob type used in the index --- tests/WP_SQLite_Translator_Tests.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/WP_SQLite_Translator_Tests.php b/tests/WP_SQLite_Translator_Tests.php index fdfb486c..33fa9ade 100644 --- a/tests/WP_SQLite_Translator_Tests.php +++ b/tests/WP_SQLite_Translator_Tests.php @@ -469,9 +469,11 @@ public function testShowCreateTableLimitsKeyLengths() { `order_id` bigint(20) unsigned DEFAULT NULL, `meta_key` varchar(20) DEFAULT NULL, `meta_value` text DEFAULT NULL, + `meta_data` mediumblob DEFAULT NULL, PRIMARY KEY (`id`), KEY `meta_key_value` (`meta_key`(20),`meta_value`(82)), - KEY `order_id_meta_key_meta_value` (`order_id`,`meta_key`(100),`meta_value`(82)) + KEY `order_id_meta_key_meta_value` (`order_id`,`meta_key`(100),`meta_value`(82)), + KEY `order_id_meta_key_meta_data` (`order_id`,`meta_key`(100),`meta_data`(100)) );' ); @@ -485,7 +487,9 @@ public function testShowCreateTableLimitsKeyLengths() { `order_id` bigint(20) unsigned DEFAULT NULL, `meta_key` varchar(20) DEFAULT NULL, `meta_value` text DEFAULT NULL, + `meta_data` mediumblob DEFAULT NULL, PRIMARY KEY (`id`), + KEY `order_id_meta_key_meta_data` (`order_id`, `meta_key`(20), `meta_data`(100)), KEY `order_id_meta_key_meta_value` (`order_id`, `meta_key`(20), `meta_value`(100)), KEY `meta_key_value` (`meta_key`(20), `meta_value`(100)) );', From 29a3cde497f3969786a8be8f14c47908d51b2044 Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Thu, 19 Dec 2024 18:55:26 +0100 Subject: [PATCH 09/13] Make condition more generic to catch any text or blob field --- wp-includes/sqlite/class-wp-sqlite-translator.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/sqlite/class-wp-sqlite-translator.php b/wp-includes/sqlite/class-wp-sqlite-translator.php index 519abc2d..25bdbc86 100644 --- a/wp-includes/sqlite/class-wp-sqlite-translator.php +++ b/wp-includes/sqlite/class-wp-sqlite-translator.php @@ -3761,14 +3761,14 @@ function ( $column ) use ( $table_name, $key_length_limit ) { $data_type = strtolower( $this->get_cached_mysql_data_type( $table_name, $column['name'] ) ); $data_length = $key_length_limit; - // Extract the length from the data type. Make it lower if needed. - if ( 1 === preg_match( '/^(\w+)\((\d+)\)$/', $data_type, $matches ) ) { + // Extract the length from the data type. Make it lower if needed. Skip 'unsigned' parts and whitespace. + if ( 1 === preg_match( '/^(\w+)\s*\(\s*(\d+)\s*\)\s*(.*)?$/', $data_type, $matches ) ) { $data_type = $matches[1]; // "varchar" $data_length = min( $matches[2], $key_length_limit ); // "255" } // Set the data length to the varchar and text key length - if ( 'text' === $data_type || str_starts_with( $data_type, 'varchar' ) ) { + if ( in_array( $this->field_types_translation[ $data_type ], [ 'text', 'blob'] ) ) { return sprintf( '`%s`(%s)', $column['name'], $data_length ); } return sprintf( '`%s`', $column['name'] ); From b98bf17a981b6e11aca670e987e578afc194d17a Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Thu, 19 Dec 2024 18:58:48 +0100 Subject: [PATCH 10/13] Use strict comparison --- wp-includes/sqlite/class-wp-sqlite-translator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-includes/sqlite/class-wp-sqlite-translator.php b/wp-includes/sqlite/class-wp-sqlite-translator.php index 25bdbc86..47b35e39 100644 --- a/wp-includes/sqlite/class-wp-sqlite-translator.php +++ b/wp-includes/sqlite/class-wp-sqlite-translator.php @@ -3768,7 +3768,7 @@ function ( $column ) use ( $table_name, $key_length_limit ) { } // Set the data length to the varchar and text key length - if ( in_array( $this->field_types_translation[ $data_type ], [ 'text', 'blob'] ) ) { + if ( in_array( $this->field_types_translation[ $data_type ], [ 'text', 'blob'], true ) ) { return sprintf( '`%s`(%s)', $column['name'], $data_length ); } return sprintf( '`%s`', $column['name'] ); From 1e086e2344edbc90fd48d809442a603090784feb Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Thu, 19 Dec 2024 19:02:14 +0100 Subject: [PATCH 11/13] Fix lint issue --- wp-includes/sqlite/class-wp-sqlite-translator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-includes/sqlite/class-wp-sqlite-translator.php b/wp-includes/sqlite/class-wp-sqlite-translator.php index 47b35e39..52cffe7b 100644 --- a/wp-includes/sqlite/class-wp-sqlite-translator.php +++ b/wp-includes/sqlite/class-wp-sqlite-translator.php @@ -3768,7 +3768,7 @@ function ( $column ) use ( $table_name, $key_length_limit ) { } // Set the data length to the varchar and text key length - if ( in_array( $this->field_types_translation[ $data_type ], [ 'text', 'blob'], true ) ) { + if ( in_array( $this->field_types_translation[ $data_type ], array( 'text', 'blob' ), true ) ) { return sprintf( '`%s`(%s)', $column['name'], $data_length ); } return sprintf( '`%s`', $column['name'] ); From c69842665fbd56ad265966d92b8b00fbcf007ba7 Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Thu, 19 Dec 2024 19:18:14 +0100 Subject: [PATCH 12/13] Use another approach to avoid catching date types --- wp-includes/sqlite/class-wp-sqlite-translator.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wp-includes/sqlite/class-wp-sqlite-translator.php b/wp-includes/sqlite/class-wp-sqlite-translator.php index 52cffe7b..824e6fb7 100644 --- a/wp-includes/sqlite/class-wp-sqlite-translator.php +++ b/wp-includes/sqlite/class-wp-sqlite-translator.php @@ -3767,8 +3767,13 @@ function ( $column ) use ( $table_name, $key_length_limit ) { $data_length = min( $matches[2], $key_length_limit ); // "255" } - // Set the data length to the varchar and text key length - if ( in_array( $this->field_types_translation[ $data_type ], array( 'text', 'blob' ), true ) ) { + // Set the data length to the varchar and text key lengths + // char, varchar, varbinary, tinyblob, tinytext, blob, text, mediumblob, mediumtext, longblob, longtext + if ( str_ends_with( $data_type, 'char' ) || + str_ends_with( $data_type, 'text' ) || + str_ends_with( $data_type, 'blob' ) || + str_starts_with( $data_type, 'var' ) + ) { return sprintf( '`%s`(%s)', $column['name'], $data_length ); } return sprintf( '`%s`', $column['name'] ); From a6c240ee3bfa8c33b75285408ae6baf9e7c7fd5a Mon Sep 17 00:00:00 2001 From: Wojtek Naruniec Date: Fri, 20 Dec 2024 10:10:51 +0100 Subject: [PATCH 13/13] clean up the regex --- wp-includes/sqlite/class-wp-sqlite-translator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-includes/sqlite/class-wp-sqlite-translator.php b/wp-includes/sqlite/class-wp-sqlite-translator.php index 824e6fb7..44996cd6 100644 --- a/wp-includes/sqlite/class-wp-sqlite-translator.php +++ b/wp-includes/sqlite/class-wp-sqlite-translator.php @@ -3762,7 +3762,7 @@ function ( $column ) use ( $table_name, $key_length_limit ) { $data_length = $key_length_limit; // Extract the length from the data type. Make it lower if needed. Skip 'unsigned' parts and whitespace. - if ( 1 === preg_match( '/^(\w+)\s*\(\s*(\d+)\s*\)\s*(.*)?$/', $data_type, $matches ) ) { + if ( 1 === preg_match( '/^(\w+)\s*\(\s*(\d+)\s*\)/', $data_type, $matches ) ) { $data_type = $matches[1]; // "varchar" $data_length = min( $matches[2], $key_length_limit ); // "255" }