Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use version_compare to compare version strings correctly #18173

Merged
merged 1 commit into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private function getGroupedDbVersionErrors()
(array)$allDbVersionErrors,
function ($carry, $item) {
if ($item[DbVersionInfo::KEY_CURRENT] === 'none'
|| $item[DbVersionInfo::KEY_CURRENT] < $item[DbVersionInfo::KEY_REQUIRED]
|| version_compare($item[DbVersionInfo::KEY_CURRENT], $item[DbVersionInfo::KEY_REQUIRED], '<')
) {
$carry['version_too_low'][] = $item;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,29 +157,29 @@ public static function beforeDispatchOutOfDateWithErrorsDataProvider()
[
DbVersionInfo::KEY_MODULE => 'Magento_Module4',
DbVersionInfo::KEY_TYPE => 'data',
DbVersionInfo::KEY_CURRENT => '1.0.1',
DbVersionInfo::KEY_REQUIRED => '1.0.0'
DbVersionInfo::KEY_CURRENT => '1.0.10',
DbVersionInfo::KEY_REQUIRED => '1.0.9'
],
],
'expectedMessage' => "Please update your modules: "
. "Run \"composer install\" from the Magento root directory.\n"
. "The following modules are outdated:\n"
. "Magento_Module3 schema: code version - 1.0.0, database version - 2.0.0\n"
. "Magento_Module4 data: code version - 1.0.0, database version - 1.0.1",
. "Magento_Module4 data: code version - 1.0.9, database version - 1.0.10",
],
'some versions too high, some too low' => [
'errors' => [
[
DbVersionInfo::KEY_MODULE => 'Magento_Module1',
DbVersionInfo::KEY_MODULE => 'Magento_Module2',
DbVersionInfo::KEY_TYPE => 'schema',
DbVersionInfo::KEY_CURRENT => '2.0.0',
DbVersionInfo::KEY_REQUIRED => '1.0.0'
DbVersionInfo::KEY_CURRENT => '1.9.0',
DbVersionInfo::KEY_REQUIRED => '1.12.0'
],
[
DbVersionInfo::KEY_MODULE => 'Magento_Module2',
DbVersionInfo::KEY_MODULE => 'Magento_Module1',
DbVersionInfo::KEY_TYPE => 'schema',
DbVersionInfo::KEY_CURRENT => '1.0.0',
DbVersionInfo::KEY_REQUIRED => '2.0.0'
DbVersionInfo::KEY_CURRENT => '2.0.0',
DbVersionInfo::KEY_REQUIRED => '1.0.0'
],
],
'expectedMessage' => "Please update your modules: "
Expand Down