diff --git a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php index f58a12dfe8..8e1ba2a187 100644 --- a/core/lib/Drupal/Core/Extension/InfoParserDynamic.php +++ b/core/lib/Drupal/Core/Extension/InfoParserDynamic.php @@ -30,7 +30,7 @@ class InfoParserDynamic implements InfoParserInterface { * @return bool * TRUE if the version satisfies the constraints, otherwise FALSE. */ - protected static function satisfies(string $version, $constraints) { + protected static function satisfies($version, $constraints) { try { return Semver::satisfies($version, $constraints); } @@ -85,7 +85,8 @@ public function parse($filename) { // Determine if the extension is compatible with the current version of // Drupal core. try { - $parsed_info['core_incompatible'] = !static::satisfies(\Drupal::VERSION, $parsed_info['core_version_requirement'] ?? $parsed_info['core']); + $core_version_constraint = isset($parsed_info['core_version_requirement']) ? $parsed_info['core_version_requirement'] : $parsed_info['core']; + $parsed_info['core_incompatible'] = !static::satisfies(\Drupal::VERSION, $core_version_constraint); } catch (\UnexpectedValueException $exception) { $parsed_info['core_incompatible'] = TRUE; @@ -138,33 +139,53 @@ protected function getRequiredKeys() { protected static function isConstraintSatisfiedByPreCoreVersionRequirementCoreVersion($constraint) { static $evaluated_constraints = []; if (!isset($evaluated_constraints[$constraint])) { + $evaluated_constraints[$constraint] = FALSE; + foreach (static::getAllPreCoreVersionRequirementCoreVersions() as $version) { + if (static::satisfies($version, $constraint)) { + $evaluated_constraints[$constraint] = TRUE; + // The constraint only has to satisfy one version so break when the + // first one is found. + break; + } + } + } + return $evaluated_constraints[$constraint]; + } + + /** + * Gets all the version of Drupal 8 before 8.7.7. + * + * @return array + * All of the applicable Drupal 8 releases. + */ + protected static function getAllPreCoreVersionRequirementCoreVersions() { + static $versions = []; + if (empty($versions)) { + // Loop through all minor versions including 8.7. foreach (range(0, 7) as $minor) { - foreach (range(0, 20) as $patch) { - $minor_version = "8.$minor.$patch"; - if ($minor_version === static::FIRST_CORE_VERSION_REQUIREMENT_SUPPORTED_VERSION) { - $evaluated_constraints[$constraint] = FALSE; - return $evaluated_constraints[$constraint]; - } - if (static::satisfies($minor_version, $constraint)) { - $evaluated_constraints[$constraint] = TRUE; - return $evaluated_constraints[$constraint]; + // The largest patch number in a release was 17 in 8.6.17. Use 27 to + // leave room for future security releases. + foreach (range(0, 27) as $patch) { + $patch_version = "8.$minor.$patch"; + if ($patch_version === static::FIRST_CORE_VERSION_REQUIREMENT_SUPPORTED_VERSION) { + // Reverse the order of the versions so that they will be evaluated + // from the most recent versions first. + $versions = array_reverse($versions); + return $versions; } + $versions[] = $patch_version; if ($patch === 0) { - foreach (['alpha', 'beta', 'rc'] as $suffix) { - foreach (range(0, 10) as $suffix_num) { - $pre_release_version = "$minor_version-$suffix$suffix_num"; - if (static::satisfies($pre_release_version, $constraint)) { - $evaluated_constraints[$constraint] = TRUE; - return $evaluated_constraints[$constraint]; - } + foreach (['alpha', 'beta', 'rc'] as $prerelease) { + // The largest prerelease number was in 8.0.0-beta16. + foreach (range(0, 16) as $prerelease_number) { + $versions[] = "$patch_version-$prerelease$prerelease_number"; } } } } } - $evaluated_constraints[$constraint] = FALSE; } - return $evaluated_constraints[$constraint]; + return $versions; } } diff --git a/core/modules/system/src/Controller/SystemController.php b/core/modules/system/src/Controller/SystemController.php index ca263a7d13..35f2228266 100644 --- a/core/modules/system/src/Controller/SystemController.php +++ b/core/modules/system/src/Controller/SystemController.php @@ -222,8 +222,6 @@ public function themesPage() { } if (empty($theme->status)) { - // Ensure this theme is compatible with this version of core. - $theme->incompatible_core = $theme->info['core_incompatible']; // Require the 'content' region to make sure the main page // content has a common place in all themes. $theme->incompatible_region = !isset($theme->info['regions']['content']); @@ -234,7 +232,7 @@ public function themesPage() { $theme->incompatible_engine = isset($theme->info['engine']) && !isset($theme->owner); } $theme->operations = []; - if (!empty($theme->status) || !$theme->incompatible_core && !$theme->incompatible_php && !$theme->incompatible_base && !$theme->incompatible_engine) { + if (!empty($theme->status) || !$theme->info['core_incompatible'] && !$theme->incompatible_php && !$theme->incompatible_base && !$theme->incompatible_engine) { // Create the operations links. $query['theme'] = $theme->getName(); if ($this->themeAccess->checkAccess($theme->getName())) { diff --git a/core/modules/system/src/Form/ModulesListForm.php b/core/modules/system/src/Form/ModulesListForm.php index af10611596..f32dad0909 100644 --- a/core/modules/system/src/Form/ModulesListForm.php +++ b/core/modules/system/src/Form/ModulesListForm.php @@ -300,7 +300,7 @@ protected function buildRow(array $modules, Extension $module, $distribution) { '@core_version' => \Drupal::VERSION, ]); $row['#requires']['core'] = $this->t('Drupal Core (@core_requirement) (incompatible with version @core_version)', [ - '@core_requirement' => $module->info['core_version_requirement'] ?? $module->info['core'], + '@core_requirement' => isset($module->info['core_version_requirement']) ? $module->info['core_version_requirement'] : $module->info['core'], '@core_version' => \Drupal::VERSION, ]); }