diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index ea3d251..3763c12 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1317,14 +1317,12 @@ function install_get_localization_release($version = \Drupal::VERSION) { // This code assumes there is a first alpha available as "alpha1". For // Drupal 8.0.0 that isn't the case. In addition the semantic versioning - // wasn't introduse before "alpha13". However, we have already gotten to + // wasn't introduced before "alpha13". However, we have already gotten to // "beta1" so we are ignoring this for now. - - // Check if the version is a regular stable release (no 'rc', 'beta', - // 'alpha', 'dev', etc.) + // Check if the version is a regular stable release (no 'rc', 'beta', 'alpha', + // 'dev', etc.) if (!isset($info['extra_text'])) { // The code below is relaxed - removing version duplicates at the end. - // First version alternative: the current version. $alternatives[] = $version; @@ -1352,8 +1350,7 @@ function install_get_localization_release($version = \Drupal::VERSION) { } else { // Below we assume that for all dev, alpha, beta or rc releases - // the patch level is 0. Modify code below and include $info['patch'] - // if the assumption is wrong. + // the patch level is 0. switch ($info['extra_text']) { // Alpha release: current alpha or previous alpha release // (e.g. 8.0.0-alpha2 falls back to 8.0.0-alpha1). @@ -1376,11 +1373,11 @@ function install_get_localization_release($version = \Drupal::VERSION) { } break; - // Dev release: The previous point release (e.g., 8.2.0-dev falls back - // to 8.1.0) or any unstable release (e.g., 8.0.0-dev falls back to + // Dev release: The previous point release (e.g., 8.2.0-dev falls back to + // 8.1.0) or any unstable release (e.g., 8.0.0-dev falls back to // 8.0.0-rc1, 8.0.0-beta1 or 8.0.0-alpha1). case 'dev': - if ($info['minor'] >= 1) { + if ($info['minor'] > 0) { $alternatives[] = $info['major'] . '.' . ($info['minor'] - 1) . '.0'; } else { @@ -1394,11 +1391,16 @@ function install_get_localization_release($version = \Drupal::VERSION) { // 8.0.0-rc2 falls back to 8.0.0-rc1) or the first beta release. case 'rc': $alternatives[] = $version; - if ($info['extra_number'] >= 2) { + if ($info['extra_number'] > 1) { $alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-rc' . ($info['extra_number'] - 1); } + // Minor releases can have rc releases, but not beta or alpha. + if ($info['minor'] > 0) { + $alternatives[] = $info['major'] . '.' . ($info['minor'] - 1) . '.0'; + $alternatives[] = $info['major'] . '.0.0'; + } else { - $alternatives[] = $info['major'] . '.' . $info['minor'] . '.0-beta1'; + $alternatives[] = $info['major'] . '.0.0-beta1'; } break; } diff --git a/core/modules/system/src/Tests/Installer/InstallerTranslationVersionUnitTest.php b/core/modules/system/src/Tests/Installer/InstallerTranslationVersionUnitTest.php index 4da8a54..6fbd348 100644 --- a/core/modules/system/src/Tests/Installer/InstallerTranslationVersionUnitTest.php +++ b/core/modules/system/src/Tests/Installer/InstallerTranslationVersionUnitTest.php @@ -99,13 +99,21 @@ public function testVersionFallback() { $this->assertVersionFallback($version, $fallback); $version = '8.0.0-rc8'; - $fallback = array('8.0.0-rc8', '8.0.0-rc7', '7.0'); + $fallback = array('8.0.0-rc8', '8.0.0-rc7', '8.0.0-beta1', '7.0'); $this->assertVersionFallback($version, $fallback); $version = '8.0.0-rc1'; $fallback = array('8.0.0-rc1', '8.0.0-beta1', '7.0'); $this->assertVersionFallback($version, $fallback); + $version = '8.2.0-rc1'; + $fallback = array('8.2.0-rc1', '8.1.0', '8.0.0', '7.0'); + $this->assertVersionFallback($version, $fallback); + + $version = '8.2.0-rc2'; + $fallback = array('8.2.0-rc2', '8.2.0-rc1', '8.1.0', '8.0.0', '7.0'); + $this->assertVersionFallback($version, $fallback); + $version = '8.0.0-foo2'; $fallback = array('7.0'); $this->assertVersionFallback($version, $fallback);