WordPress.org

Make WordPress Core

Opened 6 months ago

Last modified 6 months ago

#49364 new defect (bug)

dbDelta() should not change display width for integer data types on MySQL 8.0.17+

Reported by: SergeyBiryukov Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Database Keywords:
Focuses: Cc:

Description

Background: #49344

MySQL 8.0.17 removed support for the display width attribute for integer data types:

As of MySQL 8.0.17, the ZEROFILL attribute is deprecated for numeric data types, as is the display width attribute for integer data types. Support for ZEROFILL and display widths for integer data types will be removed in a future MySQL version. Consider using an alternative means of producing the effect of these attributes.

With this change, when creating a table, BIGINT(20) becomes just BIGINT, causing quite a few failures in tests/dbdelta.php (25 in total). They all look similar to this:

2) Tests_dbDelta::test_column_type_change
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    'wptests_dbdelta_test.id' => 'Changed type of wptests_dbdelta_test.id from bigint(20) to int(11)'
+    'wptests_dbdelta_test.id' => 'Changed type of wptests_dbdelta_test.id from bigint to int(11)'
 )

tests/phpunit/tests/dbdelta.php:151

Most of these failures will be addressed in #49344.

This ticket is for addressing the remaining failure caused by the same BIGINT(20)/BIGINT discrepancy coming from wp_get_db_schema():

1) Tests_dbDelta::test_wp_get_db_schema_does_no_alter_queries_on_existing_install                                                                           
Failed asserting that an array is empty.                                                                                                                                                                                                                                                                                
tests/phpunit/tests/dbdelta.php:693  

Currently, when running on MySQL 8.0.17+, dbDelta() tries to convert BIGINT back to BIGINT(20), INT back to INT(11), etc. This does not have any effect on the database, but is pointless and should not happen.

Change History (1)

#1 @SergeyBiryukov
6 months ago

In 47184:

Tests: Allow dbDelta() tests to (mostly) run on MySQL 8.0.11+.

  • MySQL 8.0.11 changed the GeometryCollection data type name to GeomCollection, with the latter being the preferred name.
  • MySQL 8.0.17 removed support for the display width attribute for integer data types. Previously, default display width of 20 digits was used: BIGINT(20).

The affected tests now check the MySQL server version and use the appropriate data types.

This leaves one unresolved failure on MySQL 8.0.17+ to be addressed in the future, caused by the same BIGINT display width discrepancy coming from wp_get_db_schema().

Props kaggdesign, ottok, jeremyfelt, SergeyBiryukov.
Fixes #44384, #49344. See #49364.

Note: See TracTickets for help on using tickets.