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

Issue #3249517 by phenaproxima: Ensure that all Automatic Updates event...

Issue #3249517 by phenaproxima: Ensure that all Automatic Updates event subscribers only apply to Automatic Updates uses
parent 028287ad
No related branches found
Tags 8.x-2.0-alpha1
No related merge requests found
......@@ -18,12 +18,6 @@ services:
- '@package_manager.cleaner'
- '@event_dispatcher'
- '@tempstore.shared'
automatic_updates.update_refresh_subscriber:
class: Drupal\automatic_updates\Event\UpdateRefreshSubscriber
arguments:
- '@update.manager'
tags:
- { name: event_subscriber }
automatic_updates.excluded_paths_subscriber:
class: Drupal\automatic_updates\Event\ExcludedPathsSubscriber
arguments:
......
<?php
namespace Drupal\automatic_updates\Event;
namespace Drupal\package_manager\EventSubscriber;
use Drupal\package_manager\Event\PostApplyEvent;
use Drupal\update\UpdateManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Clears stale update data once a staged update has been committed.
* Clears stale update data once staged changes have been applied.
*/
class UpdateRefreshSubscriber implements EventSubscriberInterface {
class UpdateDataSubscriber implements EventSubscriberInterface {
/**
* The update manager service.
......@@ -30,6 +30,10 @@ class UpdateRefreshSubscriber implements EventSubscriberInterface {
/**
* Clears stale update data.
*
* This will always run after any staging area is applied to the active
* directory, since it's likely that core and/or multiple extensions have been
* added, removed, or updated.
*/
public function clearData(): void {
$this->updateManager->refreshUpdateData();
......
<?php
namespace Drupal\package_manager;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceProviderBase;
use Drupal\package_manager\EventSubscriber\UpdateDataSubscriber;
use Symfony\Component\DependencyInjection\Reference;
/**
* Defines dynamic container services for Package Manager.
*/
class PackageManagerServiceProvider extends ServiceProviderBase {
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) {
parent::register($container);
if (array_key_exists('update', $container->getParameter('container.modules'))) {
$container->register('package_manager.update_data_subscriber')
->setClass(UpdateDataSubscriber::class)
->setArguments([
new Reference('update.manager'),
])
->addTag('event_subscriber');
}
}
}
......@@ -2,6 +2,7 @@
namespace Drupal\automatic_updates\Validator;
use Drupal\automatic_updates\Updater;
use Drupal\package_manager\Event\PreApplyEvent;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
......@@ -32,6 +33,11 @@ final class StagedProjectsValidator implements EventSubscriberInterface {
*/
public function validateStagedProjects(PreApplyEvent $event): void {
$stage = $event->getStage();
// We only want to do this check if the stage belongs to Automatic Updates.
if (!$stage instanceof Updater) {
return;
}
try {
$active_packages = $stage->getActiveComposer()->getDrupalExtensionPackages();
$staged_packages = $stage->getStageComposer()->getDrupalExtensionPackages();
......
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