1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-23 22:53:01 +02:00

Convert and run e107 using the MySQL/MariaDB utf8mb4 character set and

InnoDB storage engine

Components affected:
* `db_verify` now checks and corrects the table storage engine
* `db_verify` now checks and corrects the table default character set
  * Note: Field character sets can still be overridden
  * Note: When correcting, the entire table is converted to the target
    charset.
* The alt_auth plugin now connects via PDO using the e107 default
  charset, utf8mb4
* `e_db_pdo` now sets the charset to utf8mb4. This is currently not
  customizable because it was previously not customizable.
* `install.php` now generates an `e107_config.php` file with
  `$mySQLcharset = 'utf8mb4';`, though this option is not actually used.
* `install.php` now removes plugin tables before installing plugins.
* `e_db_mysql` now only accepts the `utf8mb4` charset. Previously, it
  only accepted the `utf8` charset.
* `e_db_mysql` now configures `mysqli_real_escape_string` to match the
  new default charset, `utf8mb4`.
* Plugin installations now use the preferred MySQL table storage engines
  and charsets.

The preferred MySQL table storage engines are now mapped like so:
* If `ENGINE=MyISAM` is specified, the actual storage engine set will be
  the first available of: InnoDB, Aria, Maria, MyISAM
* If `ENGINE=Aria` is specified, the actual storage engine set will be
  the first available of: Aria, Maria, MyISAM
* If `ENGINE=InnoDB` is specified, the actual storage engine set will be
  the first available of: InnoDB, XtraDB
* If `ENGINE=XtraDB` is specified, the actual storage engine set will be
  the first available of: XtraDB, InnoDB

The preferred MySQL character set is now aliased like so:
* `utf8`    => `utf8mb4`
* `utf8mb3` => `utf8mb3`
* `utf8mb4` => `utf8mb4`

Fixes: #4501
This commit is contained in:
Nick Liu
2021-05-22 00:46:35 -05:00
parent 9461602e43
commit d790faa049
12 changed files with 469 additions and 133 deletions

View File

@@ -49,6 +49,8 @@
table_summary text,
table_media text,
table_email2 tinyint(3) unsigned NOT NULL default '0',
table_email90 tinyint(3) unsigned NOT NULL default '0',
e107_name varchar(100) NOT NULL default '',
PRIMARY KEY (table_id)";
$expected = array (
@@ -188,6 +190,22 @@
'null' => 'NOT NULL',
'default' => 'DEFAULT \'0\'',
),
'table_email90' =>
array (
'type' => 'TINYINT',
'value' => '3',
'attributes' => 'UNSIGNED',
'null' => 'NOT NULL',
'default' => 'DEFAULT \'0\'',
),
'e107_name' =>
array (
'type' => 'VARCHAR',
'value' => '100',
'attributes' => '',
'null' => 'NOT NULL',
'default' => 'DEFAULT \'\'',
),
);
$actual = $this->dbv->getFields($data);
@@ -402,7 +420,7 @@ EOF;
PRIMARY KEY (table_id)
UNIQUE KEY `table_email` (`table_email`),
KEY `table_user` (`table_user`)
) ENGINE=InnoDB;';
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4;';
$expected = str_replace("\t", "",$expected);
$actual = str_replace("\t", "",$actual);
@@ -809,6 +827,11 @@ EOF;
$fileData['index'] = $this->dbv->getIndex($file);
$sqlData['index'] = $this->dbv->getIndex($sql);
$fileData['engine'] = $this->dbv->getIntendedStorageEngine("InnoDB");
$sqlData['engine'] = $this->dbv->getCanonicalStorageEngine("InnoDB");
$fileData['charset'] = $this->dbv->getIntendedCharset("utf8mb4");
$sqlData['charset'] = $this->dbv->getCanonicalCharset("utf8mb4");
$this->dbv->prepareResults('schedule', 'myplugin', $sqlData, $fileData);
@@ -946,4 +969,75 @@ EOF;
{
}*/
public function testGetCanonicalStorageEngine()
{
$input = "InnoDB";
$output = $this->dbv->getCanonicalStorageEngine($input);
$this->assertEquals($input, $output);
}
public function testGetCanonicalStorageEngineUnknownStorageEngine()
{
$this->expectException(UnexpectedValueException::class);
$this->dbv->getCanonicalStorageEngine("FakeEngine");
}
public function testGetCanonicalCharsetUtf8Alias()
{
$input = "utf8";
$expected = "utf8mb4";
$output = $this->dbv->getCanonicalCharset($input);
$this->assertEquals($expected, $output);
}
public function testGetCanonicalCharsetOther()
{
$inputs = ["latin1", "utf8mb3", "utf8mb4"];
foreach ($inputs as $input)
{
$output = $this->dbv->getCanonicalCharset($input);
$this->assertEquals($input, $output);
}
}
public function testGetIntendedStorageEngine()
{
$output = $this->dbv->getIntendedStorageEngine("MyISAM");
$this->assertEquals("InnoDB", $output);
$output = $this->dbv->getIntendedStorageEngine("InnoDB");
$this->assertEquals("InnoDB", $output);
$output = $this->dbv->getIntendedStorageEngine("Aria");
$this->assertContains($output, ["Aria", "Maria", "MyISAM"]);
$output = $this->dbv->getIntendedStorageEngine("MEMORY");
$this->assertEquals("MEMORY", $output);
}
public function testGetIntendedCharset()
{
$output = $this->dbv->getIntendedCharset("");
$this->assertEquals("utf8mb4", $output);
$output = $this->dbv->getIntendedCharset();
$this->assertEquals("utf8mb4", $output);
$output = $this->dbv->getIntendedCharset("utf8");
$this->assertEquals("utf8mb4", $output);
$output = $this->dbv->getIntendedCharset("utf8mb3");
$this->assertEquals("utf8mb3", $output);
$output = $this->dbv->getIntendedCharset("latin1");
$this->assertEquals("latin1", $output);
}
}