Skip to content

Commit

Permalink
AC-9755:Set default collation to utf8mb4 for MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
glo71317 committed Oct 28, 2024
1 parent c441b38 commit 0ed80d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ public function modifyColumn($tableName, $columnName, $definition, $flushData =
if (is_array($definition)) {
$definition = $this->_getColumnDefinition($definition);
}
// Add charset and collation for DBC failures
// Set default collation to utf8mb4 for MySQL
if (!empty($definition)) {
$type = explode(' ', trim($definition));
$definition = $this->setDefaultCharsetAndCollation($type[0], $definition, 1);
Expand Down Expand Up @@ -2446,7 +2446,7 @@ protected function _getColumnsDefinition(Table $table)
$columnDefinition
);
}
// Adding charset and collation for DBC failures
// Set default collation to utf8mb4 for MySQL
if (count($definition)) {
foreach ($definition as $index => $columnDefinition) {
$type = explode(' ', trim($columnDefinition));
Expand Down Expand Up @@ -4309,7 +4309,7 @@ public function __debugInfo()
}

/***
* Set default collation & charset (e.g.,utf8mb4_general_ci & utf8mb4) for tables
* Set default collation & charset (e.g.utf8mb4_general_ci and utf8mb4) for tables
*
* @param string $columnType
* @param string $definition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ private function getPreparedStatements(array $statementBank) : array
return $result;
}

/***
* Set default collation & charset (e.g.,utf8mb4_general_ci & utf8mb4) for tables
/**
* Set default collation & charset (e.g. utf8mb4_general_ci and utf8mb4) for tables
*
* @param string $columnDefinition
* @return string
Expand All @@ -498,7 +498,7 @@ private function setDefaultCharsetAndCollation(string $columnDefinition): string
return implode(" ", $columnsAttribute);
}

/***
/**
* Checks if any column of type varchar,char or text (mediumtext/longtext)
*
* @param string $definition
Expand Down
8 changes: 4 additions & 4 deletions setup/src/Magento/Setup/Model/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ private function setupModuleRegistry(SchemaSetupInterface $setup)
)->setComment('Module versions registry');
$connection->createTable($table);
} else {
// change the charset to utf8mb4
// Set default collation to utf8mb4 for MySQL
$getTableSchema = $connection->getCreateTable($setup->getTable('setup_module')) ?? '';
if (preg_match('/\b('. self::OLDCHARSET .')\b/', $getTableSchema)) {
$tableName = $setup->getTable('setup_module');
Expand Down Expand Up @@ -729,7 +729,7 @@ private function setupSessionTable(
);
$connection->createTable($table);
} else {
// change the charset to utf8mb4
// Set default collation to utf8mb4 for MySQL
$getTableSchema = $connection->getCreateTable($setup->getTable('session')) ?? '';
if (preg_match('/\b('. self::OLDCHARSET .')\b/', $getTableSchema)) {
$tableName = $setup->getTable('session');
Expand Down Expand Up @@ -837,7 +837,7 @@ private function setupCacheTagTable(
);
$connection->createTable($table);
} else {
// change the charset to utf8mb4
// Set default collation to utf8mb4 for MySQL
$getTableSchema = $connection->getCreateTable($setup->getTable('cache_tag')) ?? '';
if (preg_match('/\b('. self::OLDCHARSET .')\b/', $getTableSchema)) {
$tableName = $setup->getTable('cache_tag');
Expand Down Expand Up @@ -1884,7 +1884,7 @@ private function reindexAll(): void
}

/**
* Set default collation & charset (e.g.,utf8mb4_general_ci & utf8mb4) for core setup tables
* Set default collation & charset (e.g. utf8mb4_general_ci and utf8mb4) for core setup tables
*
* @param string $tableName
* @param array $columns
Expand Down

0 comments on commit 0ed80d1

Please sign in to comment.