60
60
use Magento \Store \Model \Store ;
61
61
use Magento \RemoteStorage \Setup \ConfigOptionsList as RemoteStorageValidator ;
62
62
use ReflectionException ;
63
+ use Magento \Framework \Setup \Declaration \Schema \Dto \Factories \Table as DtoFactoriesTable ;
63
64
64
65
/**
65
66
* Class Installer contains the logic to install Magento application.
@@ -259,26 +260,15 @@ class Installer
259
260
*/
260
261
private $ triggerCleaner ;
261
262
262
- /***
263
- * Charset for cl tables
264
- */
265
- private const CHARSET = 'utf8mb4 ' ;
266
-
267
- /***
268
- * Collation for cl tables
269
- */
270
- private const COLLATION = 'utf8mb4_general_ci ' ;
271
-
272
263
/***
273
264
* Old Charset for cl tables
274
265
*/
275
266
private const OLDCHARSET = 'utf8mb3 ' ;
276
267
277
268
/***
278
- * Charset and collation for column level
279
- * Adding charset and collation for DBC failures
269
+ * @var DtoFactoriesTable
280
270
*/
281
- private const COLUMN_ENCODING = " CHARACTER SET " . self :: CHARSET . " COLLATE " . self :: COLLATION ;
271
+ private $ columnConfig ;
282
272
283
273
/**
284
274
* Constructor
@@ -304,6 +294,7 @@ class Installer
304
294
* @param State $sampleDataState
305
295
* @param ComponentRegistrar $componentRegistrar
306
296
* @param PhpReadinessCheck $phpReadinessCheck
297
+ * @param DtoFactoriesTable $dtoFactoriesTable
307
298
* @throws Exception
308
299
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
309
300
*/
@@ -328,7 +319,8 @@ public function __construct(
328
319
DataSetupFactory $ dataSetupFactory ,
329
320
State $ sampleDataState ,
330
321
ComponentRegistrar $ componentRegistrar ,
331
- PhpReadinessCheck $ phpReadinessCheck
322
+ PhpReadinessCheck $ phpReadinessCheck ,
323
+ DtoFactoriesTable $ dtoFactoriesTable
332
324
) {
333
325
$ this ->filePermissions = $ filePermissions ;
334
326
$ this ->deploymentConfigWriter = $ deploymentConfigWriter ;
@@ -359,6 +351,7 @@ public function __construct(
359
351
* from that ObjectManager gets reset as different steps in the installer will write to the deployment config.
360
352
*/
361
353
$ this ->firstDeploymentConfig = ObjectManager::getInstance ()->get (DeploymentConfig::class);
354
+ $ this ->columnConfig = $ dtoFactoriesTable ;
362
355
}
363
356
364
357
/**
@@ -669,18 +662,21 @@ private function setupModuleRegistry(SchemaSetupInterface $setup)
669
662
// change the charset to utf8mb4
670
663
$ getTableSchema = $ connection ->getCreateTable ($ setup ->getTable ('setup_module ' )) ?? '' ;
671
664
if (str_contains ($ getTableSchema , self ::OLDCHARSET )) {
665
+ $ charset = $ this ->columnConfig ->getDefaultCharset ();
666
+ $ collate = $ this ->columnConfig ->getDefaultCollation ();
667
+ $ columnEncoding = " CHARACTER SET " .$ charset ." COLLATE " .$ collate ;
672
668
$ connection ->query (
673
669
sprintf (
674
670
'ALTER TABLE `%s` MODIFY COLUMN `module` varchar(50) %s,
675
671
MODIFY COLUMN `schema_version` varchar(50) %s,
676
672
MODIFY COLUMN `data_version` varchar(50) %s,
677
673
DEFAULT CHARSET=%s, DEFAULT COLLATE=%s ' ,
678
674
$ setup ->getTable ('setup_module ' ),
679
- self :: COLUMN_ENCODING ,
680
- self :: COLUMN_ENCODING ,
681
- self :: COLUMN_ENCODING ,
682
- self :: CHARSET ,
683
- self :: COLLATION
675
+ $ columnEncoding ,
676
+ $ columnEncoding ,
677
+ $ columnEncoding ,
678
+ $ charset ,
679
+ $ collate
684
680
)
685
681
);
686
682
}
@@ -747,14 +743,17 @@ private function setupSessionTable(
747
743
// change the charset to utf8mb4
748
744
$ getTableSchema = $ connection ->getCreateTable ($ setup ->getTable ('session ' )) ?? '' ;
749
745
if (str_contains ($ getTableSchema , self ::OLDCHARSET )) {
746
+ $ charset = $ this ->columnConfig ->getDefaultCharset ();
747
+ $ collate = $ this ->columnConfig ->getDefaultCollation ();
748
+ $ columnEncoding = " CHARACTER SET " .$ charset ." COLLATE " .$ collate ;
750
749
$ connection ->query (
751
750
sprintf (
752
751
'ALTER TABLE `%s` MODIFY COLUMN `session_id` varchar(255) %s ,
753
752
DEFAULT CHARSET=%s, DEFAULT COLLATE=%s ' ,
754
753
$ setup ->getTable ('session ' ),
755
- self :: COLUMN_ENCODING ,
756
- self :: CHARSET ,
757
- self :: COLLATION
754
+ $ columnEncoding ,
755
+ $ charset ,
756
+ $ collate
758
757
)
759
758
);
760
759
}
@@ -817,14 +816,17 @@ private function setupCacheTable(
817
816
// change the charset to utf8mb4
818
817
$ getTableSchema = $ connection ->getCreateTable ($ setup ->getTable ('cache ' )) ?? '' ;
819
818
if (str_contains ($ getTableSchema , self ::OLDCHARSET )) {
819
+ $ charset = $ this ->columnConfig ->getDefaultCharset ();
820
+ $ collate = $ this ->columnConfig ->getDefaultCollation ();
821
+ $ columnEncoding = " CHARACTER SET " .$ charset ." COLLATE " .$ collate ;
820
822
$ connection ->query (
821
823
sprintf (
822
824
'ALTER TABLE `%s` MODIFY COLUMN `id` varchar(200) %s,
823
825
DEFAULT CHARSET=%s, DEFAULT COLLATE=%s ' ,
824
826
$ setup ->getTable ('cache ' ),
825
- self :: COLUMN_ENCODING ,
826
- self :: CHARSET ,
827
- self :: COLLATION
827
+ $ columnEncoding ,
828
+ $ charset ,
829
+ $ collate
828
830
)
829
831
);
830
832
}
@@ -869,15 +871,18 @@ private function setupCacheTagTable(
869
871
// change the charset to utf8mb4
870
872
$ getTableSchema = $ connection ->getCreateTable ($ setup ->getTable ('cache_tag ' )) ?? '' ;
871
873
if (str_contains ($ getTableSchema , self ::OLDCHARSET )) {
874
+ $ charset = $ this ->columnConfig ->getDefaultCharset ();
875
+ $ collate = $ this ->columnConfig ->getDefaultCollation ();
876
+ $ columnEncoding = " CHARACTER SET " .$ charset ." COLLATE " .$ collate ;
872
877
$ connection ->query (
873
878
sprintf (
874
879
'ALTER TABLE `%s` MODIFY COLUMN `tag` varchar(100) %s,
875
880
MODIFY COLUMN `cache_id` varchar(200) %s, DEFAULT CHARSET=%s, DEFAULT COLLATE=%s ' ,
876
881
$ setup ->getTable ('cache_tag ' ),
877
- self :: COLUMN_ENCODING ,
878
- self :: COLUMN_ENCODING ,
879
- self :: CHARSET ,
880
- self :: COLLATION
882
+ $ columnEncoding ,
883
+ $ columnEncoding ,
884
+ $ charset ,
885
+ $ collate
881
886
)
882
887
);
883
888
}
@@ -942,15 +947,18 @@ private function setupFlagTable(
942
947
// change the charset to utf8mb4
943
948
$ getTableSchema = $ connection ->getCreateTable ($ tableName ) ?? '' ;
944
949
if (str_contains ($ getTableSchema , self ::OLDCHARSET )) {
950
+ $ charset = $ this ->columnConfig ->getDefaultCharset ();
951
+ $ collate = $ this ->columnConfig ->getDefaultCollation ();
952
+ $ columnEncoding = " CHARACTER SET " .$ charset ." COLLATE " .$ collate ;
945
953
$ connection ->query (
946
954
sprintf (
947
955
'ALTER TABLE `%s` MODIFY COLUMN `flag_code` varchar(255) %s NOT NULL,
948
956
MODIFY COLUMN `flag_data` mediumtext %s, DEFAULT CHARSET=%s, DEFAULT COLLATE=%s ' ,
949
957
$ setup ->getTable ('flag ' ),
950
- self :: COLUMN_ENCODING ,
951
- self :: COLUMN_ENCODING ,
952
- self :: CHARSET ,
953
- self :: COLLATION
958
+ $ columnEncoding ,
959
+ $ columnEncoding ,
960
+ $ charset ,
961
+ $ collate
954
962
)
955
963
);
956
964
}
0 commit comments