Skip to content

Instantly share code, notes, and snippets.

@hissy
Last active February 28, 2023 11:12
Show Gist options
  • Save hissy/ed086d6e21e52e835c9457f0d06d4176 to your computer and use it in GitHub Desktop.
Save hissy/ed086d6e21e52e835c9457f0d06d4176 to your computer and use it in GitHub Desktop.
[Concrete CMS] Delete Uncompleted Processes
<?php
$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
/** @var \Doctrine\ORM\EntityManagerInterface $em */
$em = $app->make(\Doctrine\ORM\EntityManagerInterface::class);
/** @var \Concrete\Core\Entity\Command\ProcessRepository $repository */
$repository = $em->getRepository(\Concrete\Core\Entity\Command\Process::class);
$processes = $repository->findRunning();
/** @var \Concrete\Core\Command\Process\ProcessUpdater $updater */
$updater = $app->make(\Concrete\Core\Command\Process\ProcessUpdater::class);
/** @var \Concrete\Core\Entity\Command\Process $process */
foreach ($processes as $process) {
echo sprintf('Closing Process %s (%s)', $process->getName(), $process->getID());
echo PHP_EOL;
$updater->closeProcess($process, \Concrete\Core\Command\Process\Command\ProcessMessageInterface::EXIT_CODE_FAILURE);
}
echo sprintf('Deleting Messages...');
echo PHP_EOL;
/** @var \Concrete\Core\Database\Connection\Connection $connection */
$connection = $app->make(\Concrete\Core\Database\Connection\Connection::class);
$qb = $connection->createQueryBuilder();
$qb->delete('MessengerMessages')->execute();
echo 'done';
echo PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment