Skip to content
Snippets Groups Projects
Commit 32cb8398 authored by Adrian Lorenc's avatar Adrian Lorenc
Browse files

ISAICP-9614: Use DB API instead of entity.

parent 9bec2092
No related branches found
No related tags found
2 merge requests!214ISAICP-9579: Fix SearchWidget: refer own submit callbacks precisely to prevent...,!213Release 2.3.1
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Drupal\Core\DependencyInjection\AutowireTrait; use Drupal\Core\DependencyInjection\AutowireTrait;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\joinup_assessment\AssessmentInterface;
use Drupal\mysql\Driver\Database\mysql\Connection; use Drupal\mysql\Driver\Database\mysql\Connection;
use Drush\Attributes as CLI; use Drush\Attributes as CLI;
use Drush\Commands\DrushCommands; use Drush\Commands\DrushCommands;
...@@ -54,25 +55,20 @@ public function disableDefaultWebformSanitization(InputInterface $input): void { ...@@ -54,25 +55,20 @@ public function disableDefaultWebformSanitization(InputInterface $input): void {
*/ */
#[CLI\Hook(type: HookManager::POST_COMMAND_HOOK, target: 'sql-sanitize')] #[CLI\Hook(type: HookManager::POST_COMMAND_HOOK, target: 'sql-sanitize')]
public function sanitize($result, CommandData $commandData): void { public function sanitize($result, CommandData $commandData): void {
$webformStorage = $this->entityTypeManager->getStorage('webform_submission'); $this->database->delete('webform_submission')
$querySubmission = $webformStorage->getQuery() ->condition('webform_id', AssessmentInterface::WEBFORM_ID, '!=')
->condition('webform_id', 'assessment', '!=') ->execute();
->accessCheck(FALSE);
do { $this->database->delete('webform_submission_data')
$sids = $querySubmission->range(0, 50)->execute(); ->condition('webform_id', AssessmentInterface::WEBFORM_ID, '!=')
->execute();
if (!empty($sids)) {
$webformStorage->delete(
$webformStorage->loadMultiple($sids)
);
}
} while (!empty($sids));
if ($this->moduleHandler->moduleExists('webform_submission_log')) { if ($this->moduleHandler->moduleExists('webform_submission_log')) {
$this->database->truncate('webform_submission_log')->execute(); $this->database->truncate('webform_submission_log')->execute();
} }
$this->entityTypeManager->getStorage('webform_submission')->resetCache();
$this->logger() $this->logger()
->success('Webform submission tables truncated except for the assessment.'); ->success('Webform submission tables truncated except for the assessment.');
} }
......
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