Commit 8bf145ec authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

Issue #3198309 by Gábor Hojtsy, mglaman: General Drupal 9+ compatible projects...

Issue #3198309 by Gábor Hojtsy, mglaman: General Drupal 9+ compatible projects are not necessarily Drupal 9 compatible, only if strictly 9.0.0 compatible
parent 29f33c42
......@@ -2,7 +2,6 @@
namespace Drupal\upgrade_status;
use Composer\Semver\Semver;
use Drupal\Component\Datetime\TimeInterface;
use Drupal\Component\Serialization\Yaml;
use Drupal\Component\Serialization\Exception\InvalidDataTypeException;
......@@ -379,9 +378,9 @@ final class DeprecationAnalyzer {
$result['data']['totals']['file_errors']++;
$result['data']['totals']['upgrade_status_split']['declared_ready'] = FALSE;
}
elseif (!Semver::satisfies('9.0.0', $info['core_version_requirement'])) {
elseif (!ProjectCollector::isDrupal9CompatibleConstraint($info['core_version_requirement'])) {
$result['data']['files'][$error_path]['messages'][] = [
'message' => "Value of core_version_requirement: {$info['core_version_requirement']} is not compatible with Drupal 9.0.0. See https://drupal.org/node/3070687.",
'message' => "Value of core_version_requirement: {$info['core_version_requirement']} is not compatible with Drupal 9. See https://drupal.org/node/3070687.",
'line' => 0,
];
$result['data']['totals']['errors']++;
......@@ -411,7 +410,7 @@ final class DeprecationAnalyzer {
$result['data']['totals']['file_errors']++;
$result['data']['totals']['upgrade_status_split']['declared_ready'] = FALSE;
}
elseif (!empty($composer_json->require->{'drupal/core'}) && !Semver::satisfies('9.0.0', $composer_json->require->{'drupal/core'})) {
elseif (!empty($composer_json->require->{'drupal/core'}) && !projectCollector::isDrupal9CompatibleConstraint($composer_json->require->{'drupal/core'})) {
$result['data']['files'][$extension->getPath() . '/composer.json']['messages'][] = [
'message' => "The drupal/core requirement is not Drupal 9 compatible. Either remove it or update it to be compatible with Drupal 9. See https://drupal.org/node/2514612#s-drupal-9-compatibility.",
'line' => 0,
......
......@@ -2,7 +2,8 @@
namespace Drupal\upgrade_status;
use Composer\Semver\Semver;
use Composer\Semver\VersionParser;
use Composer\Semver\Constraint\Constraint;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\Extension\ProfileExtensionList;
......@@ -210,7 +211,7 @@ class ProjectCollector {
// keep being TRUE, otherwise FALSE.
$projects[$project]->info['upgrade_status_9_compatible'] =
isset($extension->info['core_version_requirement']) &&
Semver::satisfies('9.0.0', $extension->info['core_version_requirement']);
self::isDrupal9CompatibleConstraint($extension->info['core_version_requirement']);
}
continue;
}
......@@ -252,7 +253,7 @@ class ProjectCollector {
$extdata->info['upgrade_status_type'] = $type;
$extdata->info['upgrade_status_9_compatible'] =
isset($extdata->info['core_version_requirement']) &&
Semver::satisfies('9.0.0', $extdata->info['core_version_requirement']);
self::isDrupal9CompatibleConstraint($extdata->info['core_version_requirement']);
// Save this as a possible project to consider.
$projects[$key] = $extdata;
......@@ -281,7 +282,7 @@ class ProjectCollector {
// Add Drupal 9 compatibility info from the update's data.
$latest_release = reset($project_update['releases']);
$projects[$name]->info['upgrade_status_update_compatible'] = FALSE;
if (!empty($latest_release['core_compatibility']) && Semver::satisfies('9.0.0', $latest_release['core_compatibility'])) {
if (!empty($latest_release['core_compatibility']) && self::isDrupal9CompatibleConstraint($latest_release['core_compatibility'])) {
$projects[$name]->info['upgrade_status_update_compatible'] = TRUE;
}
// Denormalize update info into the extension info for our own use.
......@@ -368,7 +369,7 @@ class ProjectCollector {
// keep being TRUE, otherwise FALSE.
$extensions[$name_a]->info['upgrade_status_9_compatible'] =
isset($extension_b->info['core_version_requirement']) &&
Semver::satisfies('9.0.0', $extension_b->info['core_version_requirement']);
self::isDrupal9CompatibleConstraint($extension_b->info['core_version_requirement']);
}
// Remove the subextension.
......@@ -492,4 +493,23 @@ class ProjectCollector {
];
}
/**
* Checks whether the given constraints are Drupal 9 compatible.
*
* A customized version of Semver::satisfies(), since that only works for
* a == condition.
*
* @paran string $constraints
* Composer compatible constraints from core_version_requirement or
* drupal/core requirement.
*
* @return bool
*/
public static function isDrupal9CompatibleConstraint(string $constraints) {
$version_parser = new VersionParser();
$provider = new Constraint('>=', $version_parser->normalize('9.0.0'));
$parsed_constraints = $version_parser->parseConstraints($constraints);
return $parsed_constraints->matches($provider);
}
}
......@@ -3,5 +3,5 @@ type: module
description: 'Support module for upgrade status module testing.'
package: Testing
version: VERSION
core_version_requirement: ^8 || ^9
core_version_requirement: ^8 || ^9.1
project: 'upgrade_status_test_contributed_no_error'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment