diff --git a/core/lib/Drupal/Core/Config/ExportStorageManager.php b/core/lib/Drupal/Core/Config/ExportStorageManager.php index 43591717abd8656b52f8e4012f8caf0a62bdf03d..fdd34cad54c201c5d61373bad1fb32823db1f80b 100644 --- a/core/lib/Drupal/Core/Config/ExportStorageManager.php +++ b/core/lib/Drupal/Core/Config/ExportStorageManager.php @@ -22,13 +22,6 @@ final class ExportStorageManager implements StorageManagerInterface { */ const LOCK_NAME = 'config_storage_export_manager'; - /** - * The active configuration storage. - * - * @var \Drupal\Core\Config\StorageInterface - */ - protected $active; - /** * The database storage. * @@ -36,20 +29,6 @@ final class ExportStorageManager implements StorageManagerInterface { */ protected $storage; - /** - * The event dispatcher. - * - * @var \Symfony\Contracts\EventDispatcher\EventDispatcherInterface - */ - protected $eventDispatcher; - - /** - * The used lock backend instance. - * - * @var \Drupal\Core\Lock\LockBackendInterface - */ - protected $lock; - /** * ExportStorageManager constructor. * @@ -57,15 +36,17 @@ final class ExportStorageManager implements StorageManagerInterface { * The active config storage to prime the export storage. * @param \Drupal\Core\Database\Connection $connection * The database connection. - * @param \Symfony\Contracts\EventDispatcher\EventDispatcherInterface $event_dispatcher + * @param \Symfony\Contracts\EventDispatcher\EventDispatcherInterface $eventDispatcher * The event dispatcher. * @param \Drupal\Core\Lock\LockBackendInterface $lock * The used lock backend instance. */ - public function __construct(StorageInterface $active, Connection $connection, EventDispatcherInterface $event_dispatcher, LockBackendInterface $lock) { - $this->active = $active; - $this->eventDispatcher = $event_dispatcher; - $this->lock = $lock; + public function __construct( + protected StorageInterface $active, + protected Connection $connection, + protected EventDispatcherInterface $eventDispatcher, + protected LockBackendInterface $lock, + ) { // The point of this service is to provide the storage and dispatch the // event when needed, so the storage itself can not be a service. $this->storage = new DatabaseStorage($connection, 'config_export'); @@ -84,7 +65,11 @@ public function getStorage() { } } + // Wrapping the queries in a transaction for performance gain. + $transaction = $this->connection->startTransaction(); self::replaceStorageContents($this->active, $this->storage); + unset($transaction); + $this->eventDispatcher->dispatch(new StorageTransformEvent($this->storage), ConfigEvents::STORAGE_TRANSFORM_EXPORT); return new ReadOnlyStorage($this->storage); diff --git a/core/lib/Drupal/Core/Config/ImportStorageTransformer.php b/core/lib/Drupal/Core/Config/ImportStorageTransformer.php index 4237f7885786c6c364e26796e02ed0374e80880f..df02d748794ec53c579168c43005ceb2cb4d8f18 100644 --- a/core/lib/Drupal/Core/Config/ImportStorageTransformer.php +++ b/core/lib/Drupal/Core/Config/ImportStorageTransformer.php @@ -114,7 +114,10 @@ public function transform(StorageInterface $storage) { } // Copy the sync configuration to the created mutable storage. + // Wrapping the queries in a transaction for performance gain. + $transaction = $this->connection->startTransaction(); self::replaceStorageContents($storage, $mutable); + unset($transaction); // Dispatch the event so that event listeners can alter the configuration. $this->eventDispatcher->dispatch(new StorageTransformEvent($mutable), ConfigEvents::STORAGE_TRANSFORM_IMPORT);