[3.x] Add collation to getAlterDbCharacterSet method of MySQLi and MySQL (PDO) drivers #331
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request for Issue joomla/joomla-cms#45112
Summary of Changes
This pull request (PR) changes the
getAlterDbCharacterSetmethod of the MySQLi and MySQL (PDO) drivers to add aCOLLATEclause to theALTER DATABASE ... CHARACTER SET ...statement.This is consistent with the method
getCreateDatabaseQueryof the same drivers, seeBoth methods are made to be used by the CMS installation and not for specifying any possible character set. They either use
utf8mb4orutf8depending onutf8mb4support of the database connection.The default character set and collation of the database are only used as default values when a
CREATE TABLEstatement does not specify character set and collation.The CMS does that always, so the database defaults do not have any impact on the CMS tables.
However, if you install a 3rd party extension which does not specify character set and collation in the
CREATE TABLEstatements in its installation SQL script, then these tables are created with a default collation which seems to depend on the MySQL or MariaDB server version (on older ones e.g.utf8mb4_general_ci, on newer ones e.g.utf8mb4_0900_ai_ci).This can lead to "Illegal mix of collations" (or so) errors when joining text columns of these tables with text columns of core tables, or when using them in a
UNIONclause of a query.Request for Comments
When this PR here is merged and the change is pulled into the CMS, tables of 3rd party extensions which do not specify character set and collation in their
CREATE TABLEstatements will be created with collationutf8mb4_unicode_ci(orutf8_unicode_ciif the database doesn't supportutf8mb4).If this is considered a b/c break then I can move this PR to 4.x-dev.
More to be done in a future PR
Since MySQL version 8.0.0 and MariaDB version 10.6.1,
utf8is replaced byutf8mb3,utf8is a an alias forutf8mb3, and that alias is deprecated and might be removed in future.Testing Instructions
See joomla/joomla-cms#45112 .
Documentation Changes Required
None.