Fix to be sure database is not created using utf8mb4 (not yet supported)
This commit is contained in:
parent
efecb32ec9
commit
aa1351d483
@ -857,6 +857,7 @@ class DoliDBMysqli extends DoliDB
|
|||||||
* Return charset used to store data in current database (same result than using SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = "databasename";)
|
* Return charset used to store data in current database (same result than using SELECT default_character_set_name FROM information_schema.SCHEMATA WHERE schema_name = "databasename";)
|
||||||
*
|
*
|
||||||
* @return string Charset
|
* @return string Charset
|
||||||
|
* @see getDefaultCollationDatabase
|
||||||
*/
|
*/
|
||||||
function getDefaultCharacterSetDatabase()
|
function getDefaultCharacterSetDatabase()
|
||||||
{
|
{
|
||||||
@ -867,7 +868,9 @@ class DoliDBMysqli extends DoliDB
|
|||||||
return $this->forcecharset;
|
return $this->forcecharset;
|
||||||
}
|
}
|
||||||
$liste=$this->fetch_array($resql);
|
$liste=$this->fetch_array($resql);
|
||||||
return $liste['Value'];
|
$tmpval = $liste['Value'];
|
||||||
|
|
||||||
|
return $tmpval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -900,6 +903,7 @@ class DoliDBMysqli extends DoliDB
|
|||||||
* Return collation used in current database
|
* Return collation used in current database
|
||||||
*
|
*
|
||||||
* @return string Collation value
|
* @return string Collation value
|
||||||
|
* @see getDefaultCharacterSetDatabase
|
||||||
*/
|
*/
|
||||||
function getDefaultCollationDatabase()
|
function getDefaultCollationDatabase()
|
||||||
{
|
{
|
||||||
@ -910,7 +914,9 @@ class DoliDBMysqli extends DoliDB
|
|||||||
return $this->forcecollate;
|
return $this->forcecollate;
|
||||||
}
|
}
|
||||||
$liste=$this->fetch_array($resql);
|
$liste=$this->fetch_array($resql);
|
||||||
return $liste['Value'];
|
$tmpval = $liste['Value'];
|
||||||
|
|
||||||
|
return $tmpval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -13,12 +13,17 @@
|
|||||||
-- flush privileges;
|
-- flush privileges;
|
||||||
|
|
||||||
|
|
||||||
-- Requests to change character set and collation of a varchar column.
|
-- Request to change default pagecode + colation of database
|
||||||
-- utf8 and utf8_unicode_ci is recommended (or even better utf8mb4 and utf8mb4_unicode_ci with mysql 5.5.3+)
|
-- ALTER DATABASE name_of_database CHARACTER SET utf8 COLLATE utf8_unicode_ci;
|
||||||
|
|
||||||
|
-- Request to change default pagecode + colation of table
|
||||||
|
-- ALTER TABLE name_of_table CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
|
||||||
|
|
||||||
|
-- Request to change character set and collation of a varchar column.
|
||||||
|
-- utf8 and utf8_unicode_ci is recommended (or even better utf8mb4 and utf8mb4_unicode_ci with mysql 5.5.3+)
|
||||||
-- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8;
|
-- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) CHARACTER SET utf8;
|
||||||
-- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci;
|
-- ALTER TABLE llx_accounting_account MODIFY account_number VARCHAR(20) COLLATE utf8_unicode_ci;
|
||||||
-- You can check with 'show full columns from llx_accounting_account';
|
-- You can check with 'show full columns from mytablename';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -16,4 +16,5 @@
|
|||||||
--
|
--
|
||||||
-- ============================================================================
|
-- ============================================================================
|
||||||
|
|
||||||
ALTER TABLE llx_product_attribute ADD CONSTRAINT unique_ref UNIQUE (ref);
|
ALTER TABLE llx_product_attribute ADD UNIQUE INDEX uk_product_attribute_ref (ref);
|
||||||
|
|
||||||
|
|||||||
@ -312,8 +312,11 @@ if (! $error && $db->connected)
|
|||||||
// Define $defaultCharacterSet and $defaultDBSortingCollation
|
// Define $defaultCharacterSet and $defaultDBSortingCollation
|
||||||
if (! $error && $db->connected)
|
if (! $error && $db->connected)
|
||||||
{
|
{
|
||||||
if (!empty($db_create_database)) { // If we create database, we force default value
|
if (!empty($db_create_database)) // If we create database, we force default value
|
||||||
$defaultCharacterSet=$db->forcecharset;
|
{
|
||||||
|
// Default values come from the database handler
|
||||||
|
|
||||||
|
$defaultCharacterSet=$db->forcecharset;
|
||||||
$defaultDBSortingCollation=$db->forcecollate;
|
$defaultDBSortingCollation=$db->forcecollate;
|
||||||
}
|
}
|
||||||
else // If already created, we take current value
|
else // If already created, we take current value
|
||||||
@ -322,6 +325,14 @@ if (! $error && $db->connected)
|
|||||||
$defaultDBSortingCollation=$db->getDefaultCollationDatabase();
|
$defaultDBSortingCollation=$db->getDefaultCollationDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force to avoid utf8mb4 because index on field char 255 reach limit of 767 char for indexes (example with mysql 5.6.34 = mariadb 10.0.29)
|
||||||
|
// TODO Remove this when utf8mb4 is supported
|
||||||
|
if ($defaultCharacterSet == 'utf8mb4' || $defaultDBSortingCollation == 'utf8mb4_unicode_ci')
|
||||||
|
{
|
||||||
|
$defaultCharacterSet = 'utf8';
|
||||||
|
$defaultDBSortingCollation = 'utf8_unicode_ci';
|
||||||
|
}
|
||||||
|
|
||||||
print '<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.'">';
|
print '<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.'">';
|
||||||
print '<input type="hidden" name="dolibarr_main_db_collation" value="'.$defaultDBSortingCollation.'">';
|
print '<input type="hidden" name="dolibarr_main_db_collation" value="'.$defaultDBSortingCollation.'">';
|
||||||
$db_character_set=$defaultCharacterSet;
|
$db_character_set=$defaultCharacterSet;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user