Skip to content
Snippets Groups Projects
Commit a303b7e9 authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3275317 by phenaproxima: If you change the path to the Composer...

Issue #3275317 by phenaproxima: If you change the path to the Composer executable, you may still see out-of-date validation errors
parent a001dacf
Branches 8.x-1.x
Tags 2.0.0-beta1 8.x-1.0-beta1
1 merge request!276Issue #3275317: If you change the path to the Composer executable, you may still see out-of-date validation errors
...@@ -137,3 +137,7 @@ services: ...@@ -137,3 +137,7 @@ services:
class: Drupal\automatic_updates\Validator\UpdateReleaseValidator class: Drupal\automatic_updates\Validator\UpdateReleaseValidator
tags: tags:
- { name: event_subscriber } - { name: event_subscriber }
automatic_updates.config_subscriber:
class: Drupal\automatic_updates\EventSubscriber\ConfigSubscriber
tags:
- { name: event_subscriber }
<?php
namespace Drupal\automatic_updates\EventSubscriber;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Clears stored validation results after certain config changes.
*
* @todo Move this functionality into ReadinessValidationManager when
* https://www.drupal.org/i/3275317#comment-14482995 is resolved.
*/
class ConfigSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
ConfigEvents::SAVE => 'onConfigSave',
];
}
/**
* Reacts when config is saved.
*
* @param \Drupal\Core\Config\ConfigCrudEvent $event
* The event object.
*/
public function onConfigSave(ConfigCrudEvent $event): void {
if ($event->getConfig()->getName() === 'package_manager.settings' && $event->isChanged('executables.composer')) {
\Drupal::service('automatic_updates.readiness_validation_manager')
->clearStoredResults();
}
}
}
...@@ -253,4 +253,27 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase { ...@@ -253,4 +253,27 @@ class ReadinessValidationManagerTest extends AutomaticUpdatesKernelTestBase {
$this->assertEmpty($manager->getResults()); $this->assertEmpty($manager->getResults());
} }
/**
* Tests that certain config changes clear stored results.
*/
public function testStoredResultsClearedOnConfigChanges(): void {
$this->enableModules(['automatic_updates']);
$results = $this->testResults['checker_1']['1 error'];
TestSubscriber1::setTestResult($results, ReadinessCheckEvent::class);
$this->assertCheckerResultsFromManager($results, TRUE);
// The results should be stored.
$this->assertCheckerResultsFromManager($results, FALSE);
// Changing the configured path to rsync should not clear the results.
$this->config('package_manager.settings')
->set('executables.rsync', '/path/to/rsync')
->save();
$this->assertCheckerResultsFromManager($results, FALSE);
// Changing the configured path to Composer should clear the results.
$this->config('package_manager.settings')
->set('executables.composer', '/path/to/composer')
->save();
$this->assertNull($this->getResultsFromManager(FALSE));
}
} }
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