Skip to content

Commit

Permalink
Backport code from #5928. (#6042)
Browse files Browse the repository at this point in the history
  • Loading branch information
brummbar authored Jun 19, 2024
1 parent a0cbfb6 commit 1cbb21f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/Drupal/Commands/sql/SanitizeSessionsCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,22 @@ public function getDatabase()
#[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');
}
}

0 comments on commit 1cbb21f

Please sign in to comment.