Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
digit-joinup-reference
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ec-europa
digit-joinup-reference
Commits
9bec2092
Commit
9bec2092
authored
3 weeks ago
by
Adrian Lorenc
Browse files
Options
Downloads
Patches
Plain Diff
Revert "ISAICP-9614: Disable sanitization."
This reverts commit
7c2ae79c
.
parent
7c2ae79c
No related branches found
No related tags found
2 merge requests
!214
ISAICP-9579: Fix SearchWidget: refer own submit callbacks precisely to prevent...
,
!213
Release 2.3.1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
web/modules/custom/joinup_assessment/src/Drush/Commands/WebformAssessmentCommands.php
+55
-1
55 additions, 1 deletion
...sessment/src/Drush/Commands/WebformAssessmentCommands.php
with
55 additions
and
1 deletion
web/modules/custom/joinup_assessment/src/Drush/Commands/WebformAssessmentCommands.php
+
55
−
1
View file @
9bec2092
...
@@ -4,18 +4,36 @@
...
@@ -4,18 +4,36 @@
namespace
Drupal\joinup_assessment\Drush\Commands
;
namespace
Drupal\joinup_assessment\Drush\Commands
;
use
Consolidation\AnnotatedCommand\CommandData
;
use
Consolidation\AnnotatedCommand\Hooks\HookManager
;
use
Consolidation\AnnotatedCommand\Hooks\HookManager
;
use
Drupal\Core\DependencyInjection\AutowireTrait
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Extension\ModuleHandlerInterface
;
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
;
use
Drush\Commands\sql\sanitize\SanitizeCommands
;
use
Drush\Commands\sql\sanitize\SanitizeCommands
;
use
Drush\Commands\sql\sanitize\SanitizePluginInterface
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\DependencyInjection\Attribute\Autowire
;
/**
/**
* Overwrites Webform Drush sanitization plugins.
* Overwrites Webform Drush sanitization plugins.
*
*
* @see \Drush\Commands\sql\sanitize\SanitizeCommands::sanitize()
* @see \Drush\Commands\sql\sanitize\SanitizeCommands::sanitize()
*/
*/
class
WebformAssessmentCommands
extends
DrushCommands
{
class
WebformAssessmentCommands
extends
DrushCommands
implements
SanitizePluginInterface
{
use
AutowireTrait
;
public
function
__construct
(
#[Autowire(service: 'database')]
protected
readonly
Connection
$database
,
protected
readonly
EntityTypeManagerInterface
$entityTypeManager
,
protected
readonly
ModuleHandlerInterface
$moduleHandler
,
)
{
parent
::
__construct
();
}
/**
/**
* Disables default webform sanitization.
* Disables default webform sanitization.
...
@@ -31,4 +49,40 @@ public function disableDefaultWebformSanitization(InputInterface $input): void {
...
@@ -31,4 +49,40 @@ public function disableDefaultWebformSanitization(InputInterface $input): void {
$input
->
setOption
(
'sanitize-webform-submissions'
,
'no'
);
$input
->
setOption
(
'sanitize-webform-submissions'
,
'no'
);
}
}
/**
* {@inheritdoc}
*/
#[CLI\Hook(type: HookManager::POST_COMMAND_HOOK, target: 'sql-sanitize')]
public
function
sanitize
(
$result
,
CommandData
$commandData
):
void
{
$webformStorage
=
$this
->
entityTypeManager
->
getStorage
(
'webform_submission'
);
$querySubmission
=
$webformStorage
->
getQuery
()
->
condition
(
'webform_id'
,
'assessment'
,
'!='
)
->
accessCheck
(
FALSE
);
do
{
$sids
=
$querySubmission
->
range
(
0
,
50
)
->
execute
();
if
(
!
empty
(
$sids
))
{
$webformStorage
->
delete
(
$webformStorage
->
loadMultiple
(
$sids
)
);
}
}
while
(
!
empty
(
$sids
));
if
(
$this
->
moduleHandler
->
moduleExists
(
'webform_submission_log'
))
{
$this
->
database
->
truncate
(
'webform_submission_log'
)
->
execute
();
}
$this
->
logger
()
->
success
(
'Webform submission tables truncated except for the assessment.'
);
}
/**
* {@inheritdoc}
*/
#[CLI\Hook(type: HookManager::ON_EVENT, target: SanitizeCommands::CONFIRMS)]
public
function
messages
(
&
$messages
,
InputInterface
$input
)
:
void
{
$messages
[]
=
dt
(
'Sanitize webform submission data except for the assessment.'
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment