Skip to content

Commit a284270

Browse files
committed
Validate access on each submitted entity for bulk action
1 parent 7b56c37 commit a284270

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.9.5] - 2022-1-11
8+
### Fixed
9+
- Validate access on each submitted entity for bulk action
10+
711
## [1.9.4] - 2021-12-16
812
### Fixed
913
- Fix PHP 8.1 warnings

src/Form/BulkActionForm.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,21 @@ public function validateForm(array &$form, FormStateInterface $formState): void
140140
$subFormState = SubformState::createForSubform($form['configuration']['form'], $form, $formState);
141141
$entities = $this->getEntities($formState);
142142

143+
if ($action instanceof ActionInterface) {
144+
foreach ($entities as $entity) {
145+
if (!$action->access($entity)) {
146+
$formState->setErrorByName(
147+
sprintf('%s:%s', $entity->getEntityTypeId(), $entity->bundle()),
148+
sprintf(
149+
'"%s" is not allowed in "%s" Bulk operation',
150+
$entity->label(),
151+
(string) ($action->getPluginDefinition()['label'] ?? $action->getPluginId())
152+
)
153+
);
154+
}
155+
}
156+
}
157+
143158
if ($action instanceof PluginFormInterface) {
144159
$action->validateConfigurationForm($form, $subFormState);
145160
}

0 commit comments

Comments
 (0)