Skip to content
Snippets Groups Projects
Commit be131cb3 authored by Theresa Grannum's avatar Theresa Grannum Committed by Adam G-H
Browse files

Issue #3308365 by phenaproxima, Theresa.Grannum: Don't allow Drupal profiles...

Issue #3308365 by phenaproxima, Theresa.Grannum: Don't allow Drupal profiles to be sent to ExtensionUpdater
parent d0685981
No related branches found
No related tags found
1 merge request!476Issue #3308365: Don't allow Drupal profiles to be sent to ExtensionUpdater
......@@ -42,11 +42,18 @@ class ExtensionUpdater extends Stage {
$require_dev = $composer->getComposer()
->getPackage()
->getDevRequires();
$installed_packages = $composer->getInstalledPackages();
foreach ($project_versions as $project_name => $version) {
$package = $composer->getPackageForProject($project_name);
if (empty($package)) {
throw new \InvalidArgumentException("The project $project_name is not a Drupal project known to Composer and cannot be updated.");
}
// We don't support updating install profiles.
if ($installed_packages[$package]->getType() === 'drupal-profile') {
throw new \InvalidArgumentException("The project $project_name cannot be updated because updating install profiles is not supported.");
}
$group = array_key_exists($package, $require_dev) ? 'dev' : 'production';
$package_versions[$group][$package] = LegacyVersionUtility::convertToSemanticVersion($version);
}
......
{
"require": {
"drupal/core-recommended": "^9",
"drupal/my_module": "^9"
"drupal/my_module": "^9",
"drupal/contrib_profile1": "*"
},
"require-dev": {
"drupal/my_dev_module": "^9"
......
......@@ -9,13 +9,35 @@
},
{
"name": "drupal/my_module",
"version": "9.8.0"
"version": "9.8.0",
"type": "drupal-module"
},
{
"name": "drupal/contrib_profile1",
"version": "1.0.0",
"type": "drupal-profile"
},
{
"name": "drupal/semver_test",
"version": "1.0.0",
"type": "drupal-module"
},
{
"name": "drupal/aaa_update_test",
"version": "1.0.0",
"type": "drupal-module"
},
{
"name": "drupal/aaa_automatic_updates_test",
"version": "1.0.0",
"type": "drupal-module"
}
],
"packages-dev": [
{
"name": "drupal/my_dev_module",
"version": "9.8.1"
"version": "9.8.1",
"type": "drupal-module"
}
]
}
......@@ -18,11 +18,33 @@
},
{
"name": "drupal/my_module",
"version": "9.8.0"
"version": "9.8.0",
"type": "drupal-module"
},
{
"name": "drupal/contrib_profile1",
"version": "1.0.0",
"type": "drupal-profile"
},
{
"name": "drupal/my_dev_module",
"version": "9.8.1"
"version": "9.8.1",
"type": "drupal-module"
},
{
"name": "drupal/semver_test",
"version": "1.0.0",
"type": "drupal-module"
},
{
"name": "drupal/aaa_update_test",
"version": "1.0.0",
"type": "drupal-module"
},
{
"name": "drupal/aaa_automatic_updates_test",
"version": "1.0.0",
"type": "drupal-module"
}
],
"dev": true,
......
......@@ -11,6 +11,10 @@ return [
'type' => 'drupal-module',
'install_path' => $projects_dir . '/my_module',
],
'drupal/contrib_profile1' => [
'type' => 'drupal-profile',
'install_path' => __DIR__ . '/../../web/profiles/contrib_profile1',
],
'drupal/my_dev_module' => [
'type' => 'drupal-module',
'install_path' => $projects_dir . '/my_dev_module',
......
project: contrib_profile1
type: profile
......@@ -113,6 +113,19 @@ class ExtensionUpdaterTest extends AutomaticUpdatesKernelTestBase {
}
}
/**
* Tests that attempting to update an install profile throws an exception.
*/
public function testUpdatingInstallProfile(): void {
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage("The project contrib_profile1 cannot be updated because updating install profiles is not supported.");
$this->container->get('automatic_updates_extensions.updater')
->begin([
'contrib_profile1' => '1.1.0',
]);
}
/**
* Tests that an exception is thrown when calling begin() with no projects.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment