Issue #3437409 ForbidCoreChangesValidator.php
Closes #3437409
Merge request reports
Activity
- Resolved by Ted Bowman
- Resolved by Ted Bowman
- Resolved by Ted Bowman
92 * it ensures that the 'drupal/core' is included in the list if present. 93 * 94 * @param string $composer_root 95 * The path to the composer root. 96 * 97 * @return \Drupal\package_manager\InstalledPackagesList 98 * The installed core packages. 99 */ 100 private function getInstalledCorePackages(string $composer_root): InstalledPackagesList { 101 $installed_package_list = $this->composerInspector->getInstalledPackagesList($composer_root); 102 $core_packages = $installed_package_list->getCorePackages(); 103 if (isset($installed_package_list['drupal/core']) && !isset($core_packages['drupal/core'])) { 104 $core_packages = new InstalledPackagesList(array_merge($core_packages->getArrayCopy(), ['drupal/core' => $installed_package_list['drupal/core']])); 105 } 106 return $core_packages; 107 } - Comment on lines +100 to +107
I don't understand why we need this.
drupal/core
ordrupal/core-recommended
will be in here somewhere, right?IMHO this should be moved to a new method of
InstalledPackagesList
, calledhasDrupalCore()
. It would return TRUE if eitherdrupal/core
ordrupal/core-recommended
were there.public function hasDrupalCore(): bool { return isset($this['drupal/core']) || isset($this['drupal/core-recommended']); }
Or, we could add a new bool param to
getCorePackages()
which doesn't removedrupal/core
ifdrupal/core-recommended
is there. (TBH I kind of like this idea better.)Edited by Adam G-H I would rather not make any changes to the main module in this issue. It is currently needed because
\Drupal\package_manager\ComposerInspector::getInstalledPackagesList()
becausedrupal/core
could removed from the packages list.I think this validator should just throw an error any packages that we consider "core", \Drupal\package_manager\InstalledPackagesList::getCorePackageList are changed.
44 * @param \Drupal\package_manager\Event\StatusCheckEvent|\Drupal\package_manager\Event\PreApplyEvent $event 45 * The event object. 46 */ 47 public function validateStagedCorePackages(StatusCheckEvent|PreApplyEvent $event): void { 48 $stage = $event->stage; 49 // We only want to do this check if the stage belongs to Automatic Updates 50 // Extensions. 51 if ($stage->getType() !== 'automatic_updates_extensions:attended' || !$stage->stageDirectoryExists()) { 52 return; 53 } 54 $active_core_packages = $this->getInstalledCorePackages($this->pathLocator->getProjectRoot()); 55 $stage_core_packages = $this->getInstalledCorePackages($stage->getStageDirectory()); 56 57 $new_packages = $stage_core_packages->getPackagesNotIn($active_core_packages); 58 $removed_packages = $active_core_packages->getPackagesNotIn($stage_core_packages); 59 $changed_packages = $active_core_packages->getPackagesWithDifferentVersionsIn($stage_core_packages); - Resolved by Ted Bowman
- Resolved by Ted Bowman
- Resolved by Ted Bowman
- Resolved by Ted Bowman
added 3 commits
-
8817d4b7...b5cf0c88 - 2 commits from branch
project:3.0.x
- d5b8d0ac - Merge branch '3.0.x' into 3437409-dont-allow-core
-
8817d4b7...b5cf0c88 - 2 commits from branch
added 3 commits
-
afca55cb...56e2a789 - 2 commits from branch
project:3.0.x
- 1227dd21 - Merge branch '3.0.x' into 3437409-dont-allow-core
-
afca55cb...56e2a789 - 2 commits from branch