From a7f9dcbd1c00f07a1a41dcd41be3fcde6cc4a173 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Sat, 23 Mar 2024 12:11:53 -0400 Subject: [PATCH] Account for D11 changes (#5928) --- src/Commands/config/ConfigImportCommands.php | 5 ++-- .../sql/sanitize/SanitizeSessionsCommands.php | 24 +++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/Commands/config/ConfigImportCommands.php b/src/Commands/config/ConfigImportCommands.php index bbad59b1b4..6fff27504f 100644 --- a/src/Commands/config/ConfigImportCommands.php +++ b/src/Commands/config/ConfigImportCommands.php @@ -258,7 +258,9 @@ public function doImport($storage_comparer): void do { $config_importer->doSyncStep($step, $context); if (isset($context['message'])) { - $this->logger()->notice(str_replace('Synchronizing', 'Synchronized', (string)$context['message'])); + $this->logger()->notice( + str_replace('Synchronizing', 'Synchronized', (string)$context['message']) + ); } } while ($context['finished'] < 1); } @@ -280,7 +282,6 @@ public function doImport($storage_comparer): void $message = 'The import failed due to the following reasons:' . "\n"; $message .= implode("\n", $config_importer->getErrors()); - watchdog_exception('config_import', $e); throw new \Exception($message, $e->getCode(), $e); } finally { // Importing config might trigger batch operations (such as when installing and uninstalling modules). diff --git a/src/Commands/sql/sanitize/SanitizeSessionsCommands.php b/src/Commands/sql/sanitize/SanitizeSessionsCommands.php index 42a2f3b8d3..bb2edc6247 100644 --- a/src/Commands/sql/sanitize/SanitizeSessionsCommands.php +++ b/src/Commands/sql/sanitize/SanitizeSessionsCommands.php @@ -24,28 +24,28 @@ public function __construct(protected Connection $database) parent::__construct(); } - /** - * @return mixed - */ - public function getDatabase() - { - return $this->database; - } - - /** * Sanitize sessions from the DB. */ #[CLI\Hook(type: HookManager::POST_COMMAND_HOOK, target: SanitizeCommands::SANITIZE)] public function sanitize($result, CommandData $commandData): void { - $this->getDatabase()->truncate('sessions')->execute(); - $this->logger()->success(dt('Sessions table truncated.')); + if ($this->applies()) { + $this->database->truncate('sessions')->execute(); + $this->logger()->success(dt('Sessions table truncated.')); + } } #[CLI\Hook(type: HookManager::ON_EVENT, target: SanitizeCommands::CONFIRMS)] public function messages(&$messages, InputInterface $input): void { - $messages[] = dt('Truncate sessions table.'); + if ($this->applies()) { + $messages[] = dt('Truncate sessions table.'); + } + } + + private function applies(): bool + { + return $this->database->schema()->tableExists('sessions'); } }