Merge #20262 - Fix #18204 - Remove getInnodbPluginVersion() and refactor getInnodbFileFormat() for MariaDB compatibility
Pull-request: #20262 Co-Authored-By: William Desportes <williamdes@wdes.fr> Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
commit
9d2f4c7247
@ -7,6 +7,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace PhpMyAdmin\Engines;
|
||||
|
||||
use PhpMyAdmin\DatabaseInterface;
|
||||
use PhpMyAdmin\StorageEngine;
|
||||
use PhpMyAdmin\Util;
|
||||
|
||||
@ -281,18 +282,6 @@ class Innodb extends StorageEngine
|
||||
return 'innodb-storage-engine';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the InnoDB plugin version number
|
||||
*
|
||||
* @return string the version number, or empty if not running as a plugin
|
||||
*/
|
||||
public function getInnodbPluginVersion()
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
return $dbi->fetchValue('SELECT @@innodb_version;') ?: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the InnoDB file format
|
||||
*
|
||||
@ -302,17 +291,22 @@ class Innodb extends StorageEngine
|
||||
*/
|
||||
public function getInnodbFileFormat(): ?string
|
||||
{
|
||||
/** @var DatabaseInterface $dbi */// phpcs:ignore
|
||||
global $dbi;
|
||||
|
||||
$value = $dbi->fetchValue("SHOW GLOBAL VARIABLES LIKE 'innodb_file_format';", 1);
|
||||
if (
|
||||
($dbi->isMariaDB() && $dbi->getVersion() >= 100600)
|
||||
|| ($dbi->isMySql() && $dbi->getVersion() >= 80000)
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$value = $dbi->fetchValue("SHOW GLOBAL VARIABLES LIKE 'innodb_file_format';", 1);
|
||||
if ($value === false) {
|
||||
// This variable does not exist anymore on MariaDB >= 10.6.0
|
||||
// This variable does not exist anymore on MySQL >= 8.0.0
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string) $value;
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -519,11 +519,7 @@ class Operations
|
||||
|
||||
/** @var Innodb $innodbEnginePlugin */
|
||||
$innodbEnginePlugin = StorageEngine::getEngine('Innodb');
|
||||
$innodbPluginVersion = $innodbEnginePlugin->getInnodbPluginVersion();
|
||||
$innodb_file_format = '';
|
||||
if (! empty($innodbPluginVersion)) {
|
||||
$innodb_file_format = $innodbEnginePlugin->getInnodbFileFormat() ?? '';
|
||||
}
|
||||
$innodb_file_format = $innodbEnginePlugin->getInnodbFileFormat() ?? '';
|
||||
|
||||
/**
|
||||
* Newer MySQL/MariaDB always return empty a.k.a '' on $innodb_file_format otherwise
|
||||
|
||||
@ -16777,21 +16777,16 @@ parameters:
|
||||
|
||||
-
|
||||
message: "#^Cannot call method fetchValue\\(\\) on mixed\\.$#"
|
||||
count: 4
|
||||
path: libraries/classes/Engines/Innodb.php
|
||||
|
||||
-
|
||||
message: "#^Cannot cast mixed to string\\.$#"
|
||||
count: 2
|
||||
path: libraries/classes/Engines/Innodb.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Engines\\\\Innodb\\:\\:getInfoPages\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
message: "#^Cannot cast mixed to string\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Engines/Innodb.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Engines\\\\Innodb\\:\\:getInnodbPluginVersion\\(\\) should return string but returns mixed\\.$#"
|
||||
message: "#^Method PhpMyAdmin\\\\Engines\\\\Innodb\\:\\:getInfoPages\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Engines/Innodb.php
|
||||
|
||||
@ -16810,11 +16805,6 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/Engines/Innodb.php
|
||||
|
||||
-
|
||||
message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/Engines/Innodb.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpMyAdmin\\\\Engines\\\\Memory\\:\\:getVariables\\(\\) return type has no value type specified in iterable type array\\.$#"
|
||||
count: 1
|
||||
@ -23892,7 +23882,7 @@ parameters:
|
||||
|
||||
-
|
||||
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
|
||||
count: 11
|
||||
count: 10
|
||||
path: libraries/classes/Operations.php
|
||||
|
||||
-
|
||||
|
||||
@ -226,14 +226,6 @@ class InnodbTest extends AbstractTestCase
|
||||
self::assertSame('innodb-storage-engine', $this->object->getMysqlHelpPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getInnodbPluginVersion
|
||||
*/
|
||||
public function testGetInnodbPluginVersion(): void
|
||||
{
|
||||
self::assertSame('1.1.8', $this->object->getInnodbPluginVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for supportsFilePerTable
|
||||
*/
|
||||
@ -260,7 +252,9 @@ class InnodbTest extends AbstractTestCase
|
||||
$dbi = $this->createStub(DatabaseInterface::class);
|
||||
|
||||
$dbi->method('isMariaDB')->willReturn(false);
|
||||
$dbi->method('isMySql')->willReturn(true);
|
||||
$dbi->method('getVersion')->willReturn(80000);
|
||||
$dbi->method('fetchValue')->willReturn('Barracuda');
|
||||
|
||||
self::assertSame('', $this->object->getInnodbFileFormat());
|
||||
}
|
||||
@ -275,9 +269,28 @@ class InnodbTest extends AbstractTestCase
|
||||
$dbi = $this->createStub(DatabaseInterface::class);
|
||||
|
||||
$dbi->method('isMariaDB')->willReturn(false);
|
||||
$dbi->method('isMySql')->willReturn(true);
|
||||
$dbi->method('getVersion')->willReturn(50000);
|
||||
$dbi->method('fetchValue')->willReturn('Barracuda');
|
||||
|
||||
self::assertSame('', $this->object->getInnodbFileFormat());
|
||||
self::assertSame('Barracuda', $this->object->getInnodbFileFormat());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getInnodbFileFormat on MySQL 5 with error
|
||||
*/
|
||||
public function testGetInnodbFileFormatOnMySQL5WithError(): void
|
||||
{
|
||||
global $dbi;
|
||||
|
||||
$dbi = $this->createStub(DatabaseInterface::class);
|
||||
|
||||
$dbi->method('isMariaDB')->willReturn(false);
|
||||
$dbi->method('isMySql')->willReturn(true);
|
||||
$dbi->method('getVersion')->willReturn(50000);
|
||||
$dbi->method('fetchValue')->willReturn(false);
|
||||
|
||||
self::assertNull($this->object->getInnodbFileFormat());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -290,7 +303,9 @@ class InnodbTest extends AbstractTestCase
|
||||
$dbi = $this->createStub(DatabaseInterface::class);
|
||||
|
||||
$dbi->method('isMariaDB')->willReturn(true);
|
||||
$dbi->method('isMySql')->willReturn(false);
|
||||
$dbi->method('getVersion')->willReturn(100600);
|
||||
$dbi->method('fetchValue')->willReturn('Barracuda');
|
||||
|
||||
self::assertSame('', $this->object->getInnodbFileFormat());
|
||||
}
|
||||
|
||||
@ -705,12 +705,6 @@ class DbiDummy implements DbiExtension
|
||||
'query' => 'SHOW ENGINE INNODB STATUS;',
|
||||
'result' => false,
|
||||
],
|
||||
[
|
||||
'query' => 'SELECT @@innodb_version;',
|
||||
'result' => [
|
||||
['1.1.8'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'query' => 'SELECT @@disabled_storage_engines',
|
||||
'result' => [
|
||||
|
||||
Loading…
Reference in New Issue
Block a user