From d26b9fb543cfe63c7383585e9b9785fcf1cf6920 Mon Sep 17 00:00:00 2001 From: Gaurav Punjabi Date: Mon, 6 Jan 2020 17:20:03 +0530 Subject: [PATCH 1/4] Added a condition to find the latest compatible version Signed-off-by: Gaurav Punjabi --- libraries/classes/VersionInformation.php | 25 +++++++++---- test/classes/VersionInformationTest.php | 46 ++++++++++++++++++++++-- 2 files changed, 62 insertions(+), 9 deletions(-) diff --git a/libraries/classes/VersionInformation.php b/libraries/classes/VersionInformation.php index e6f42dbfad5b..6b6de9a6a181 100644 --- a/libraries/classes/VersionInformation.php +++ b/libraries/classes/VersionInformation.php @@ -141,6 +141,8 @@ public function versionToInt($version) */ public function getLatestCompatibleVersion(array $releases) { + // Maintains the latest compatible version + $latestRelease = null; foreach ($releases as $release) { $phpVersions = $release->php_versions; $phpConditions = explode(",", $phpVersions); @@ -150,7 +152,7 @@ public function getLatestCompatibleVersion(array $releases) } } - // We evalute MySQL version constraint if there are only + // We evaluate MySQL version constraint if there are only // one server configured. if (count($GLOBALS['cfg']['Servers']) === 1) { $mysqlVersions = $release->mysql_versions; @@ -161,15 +163,24 @@ public function getLatestCompatibleVersion(array $releases) } } } - - return [ - 'version' => $release->version, - 'date' => $release->date, - ]; + // To compare the current release with the previous latest release + if ($latestRelease) { + if ($latestRelease['version'] < $release->version) { + $latestRelease = [ + 'version' => $release->version, + 'date' => $release->date + ]; + } + } else { + $latestRelease = [ + 'version' => $release->version, + 'date' => $release->date, + ]; + } } // no compatible version - return null; + return $latestRelease; } /** diff --git a/test/classes/VersionInformationTest.php b/test/classes/VersionInformationTest.php index 69497d0079b1..86e43856ff55 100644 --- a/test/classes/VersionInformationTest.php +++ b/test/classes/VersionInformationTest.php @@ -221,7 +221,7 @@ public function testGetLatestCompatibleVersionWithSingleServer() * * @return void */ - public function testGetLaestCompatibleVersionWithMultipleServers() + public function testGetLatestCompatibleVersionWithMultipleServers() { $GLOBALS['cfg']['Servers'] = [ [], @@ -252,7 +252,7 @@ public function testGetLaestCompatibleVersionWithMultipleServers() * * @return void */ - public function testGetLaestCompatibleVersionWithOldPHPVersion() + public function testGetLatestCompatibleVersionWithOldPHPVersion() { $GLOBALS['cfg']['Servers'] = [ [], @@ -288,6 +288,48 @@ public function testGetLaestCompatibleVersionWithOldPHPVersion() $this->assertEquals('4.0.10.10', $compatible['version']); } + + /** + * Tests getLatestCompatibleVersion() with an new PHP version + * + * @return void + */ + public function testGetLatestCompatibleVersionWithNewPHPVersion() + { + $GLOBALS['cfg']['Servers'] = [ + [], + [], + ]; + + $mockVersionInfo = $this->getMockBuilder('PhpMyAdmin\VersionInformation') + ->setMethods(['evaluateVersionCondition']) + ->getMock(); + + $mockVersionInfo->expects($this->at(0)) + ->method('evaluateVersionCondition') + ->with('PHP', '>=7.1') + ->will($this->returnValue(true)); + + $mockVersionInfo->expects($this->at(1)) + ->method('evaluateVersionCondition') + ->with('PHP', '>=5.3') + ->will($this->returnValue(true)); + + $mockVersionInfo->expects($this->at(2)) + ->method('evaluateVersionCondition') + ->with('PHP', '>=5.2') + ->will($this->returnValue(true)); + + $mockVersionInfo->expects($this->at(3)) + ->method('evaluateVersionCondition') + ->with('PHP', '<5.3') + ->will($this->returnValue(false)); + + $compatible = $mockVersionInfo + ->getLatestCompatibleVersion($this->_releases); + $this->assertEquals('5.0.0', $compatible['version']); + } + /** * Tests evaluateVersionCondition() method * From 87aa7b0dc7e0913f4f4eed8f30475a8c37d9e050 Mon Sep 17 00:00:00 2001 From: Gaurav Punjabi Date: Mon, 6 Jan 2020 17:20:03 +0530 Subject: [PATCH 2/4] Revert "Added a condition to find the latest compatible version" This reverts commit d26b9fb543cfe63c7383585e9b9785fcf1cf6920. Sorry for that error Signed-off-by: William Desportes --- libraries/classes/VersionInformation.php | 25 ++++--------- test/classes/VersionInformationTest.php | 46 ++---------------------- 2 files changed, 9 insertions(+), 62 deletions(-) diff --git a/libraries/classes/VersionInformation.php b/libraries/classes/VersionInformation.php index 6b6de9a6a181..e6f42dbfad5b 100644 --- a/libraries/classes/VersionInformation.php +++ b/libraries/classes/VersionInformation.php @@ -141,8 +141,6 @@ public function versionToInt($version) */ public function getLatestCompatibleVersion(array $releases) { - // Maintains the latest compatible version - $latestRelease = null; foreach ($releases as $release) { $phpVersions = $release->php_versions; $phpConditions = explode(",", $phpVersions); @@ -152,7 +150,7 @@ public function getLatestCompatibleVersion(array $releases) } } - // We evaluate MySQL version constraint if there are only + // We evalute MySQL version constraint if there are only // one server configured. if (count($GLOBALS['cfg']['Servers']) === 1) { $mysqlVersions = $release->mysql_versions; @@ -163,24 +161,15 @@ public function getLatestCompatibleVersion(array $releases) } } } - // To compare the current release with the previous latest release - if ($latestRelease) { - if ($latestRelease['version'] < $release->version) { - $latestRelease = [ - 'version' => $release->version, - 'date' => $release->date - ]; - } - } else { - $latestRelease = [ - 'version' => $release->version, - 'date' => $release->date, - ]; - } + + return [ + 'version' => $release->version, + 'date' => $release->date, + ]; } // no compatible version - return $latestRelease; + return null; } /** diff --git a/test/classes/VersionInformationTest.php b/test/classes/VersionInformationTest.php index 86e43856ff55..69497d0079b1 100644 --- a/test/classes/VersionInformationTest.php +++ b/test/classes/VersionInformationTest.php @@ -221,7 +221,7 @@ public function testGetLatestCompatibleVersionWithSingleServer() * * @return void */ - public function testGetLatestCompatibleVersionWithMultipleServers() + public function testGetLaestCompatibleVersionWithMultipleServers() { $GLOBALS['cfg']['Servers'] = [ [], @@ -252,7 +252,7 @@ public function testGetLatestCompatibleVersionWithMultipleServers() * * @return void */ - public function testGetLatestCompatibleVersionWithOldPHPVersion() + public function testGetLaestCompatibleVersionWithOldPHPVersion() { $GLOBALS['cfg']['Servers'] = [ [], @@ -288,48 +288,6 @@ public function testGetLatestCompatibleVersionWithOldPHPVersion() $this->assertEquals('4.0.10.10', $compatible['version']); } - - /** - * Tests getLatestCompatibleVersion() with an new PHP version - * - * @return void - */ - public function testGetLatestCompatibleVersionWithNewPHPVersion() - { - $GLOBALS['cfg']['Servers'] = [ - [], - [], - ]; - - $mockVersionInfo = $this->getMockBuilder('PhpMyAdmin\VersionInformation') - ->setMethods(['evaluateVersionCondition']) - ->getMock(); - - $mockVersionInfo->expects($this->at(0)) - ->method('evaluateVersionCondition') - ->with('PHP', '>=7.1') - ->will($this->returnValue(true)); - - $mockVersionInfo->expects($this->at(1)) - ->method('evaluateVersionCondition') - ->with('PHP', '>=5.3') - ->will($this->returnValue(true)); - - $mockVersionInfo->expects($this->at(2)) - ->method('evaluateVersionCondition') - ->with('PHP', '>=5.2') - ->will($this->returnValue(true)); - - $mockVersionInfo->expects($this->at(3)) - ->method('evaluateVersionCondition') - ->with('PHP', '<5.3') - ->will($this->returnValue(false)); - - $compatible = $mockVersionInfo - ->getLatestCompatibleVersion($this->_releases); - $this->assertEquals('5.0.0', $compatible['version']); - } - /** * Tests evaluateVersionCondition() method * From aadade55ce342891b53b082f1be32cac40b3114d Mon Sep 17 00:00:00 2001 From: Jayati Shrivastava Date: Mon, 3 Feb 2020 18:19:36 +0530 Subject: [PATCH 3/4] Fix #15795 - Broken link on "MySQL said" Signed-off-by: Jayati Shrivastava --- libraries/classes/Util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/classes/Util.php b/libraries/classes/Util.php index 35d8a9325df6..f1cb338cf750 100644 --- a/libraries/classes/Util.php +++ b/libraries/classes/Util.php @@ -665,7 +665,7 @@ public static function mysqlDie( // Adds a link to MySQL documentation. $error_msg .= '

' . "\n" . ' ' . __('MySQL said: ') . '' - . self::showMySQLDocu('Error-messages-server') + . self::showMySQLDocu('server-error-reference') . "\n" . '

' . "\n"; From 7b81e8f975fe9c8971284bcf2ce05d8121909965 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Wed, 12 Feb 2020 22:39:44 +0100 Subject: [PATCH 4/4] Add ChangeLog entry for #15795 Signed-off-by: William Desportes --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index a75cad7e657e..debe1fa5eea7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -38,6 +38,7 @@ phpMyAdmin - ChangeLog - issue #15410 Fixed auto increment reset issue where the last value of AI was saved an could destroy the "good" value - issue #15187 Fixed editing a row and using 'insert as new row' uses primary key 0 instead of NULL - issue #15877 Fixed php error "preg_match() expects parameter 2 to be string, null given" on some specific tables +- issue #15795 Fix broken link on "MySQL said" error message 5.0.1 (2020-01-07) - issue #15719 Fixed error 500 when browsing a table when $cfg['LimitChars'] used a string and not an int value