Skip to content

Commit 1b27d0d

Browse files
committed
Added check for missing webform
1 parent 902d619 commit 1b27d0d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/WebformHelper.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,20 @@ public function fileDownload(string $uri) {
255255
return -1;
256256
}
257257

258-
// User has API access.
259-
$webform = \Drupal::entityTypeManager()->getStorage('webform')->load($matches['webform']);
260-
$allowedUsers = $this->getAllowedUsers($webform);
258+
// User has API access. Try to load the webform.
259+
$webform = $this->getWebform($matches['webform']);
260+
if (NULL === $webform) {
261+
// Deny access if webform cannot be loaded.
262+
return -1;
263+
}
261264

265+
$allowedUsers = $this->getAllowedUsers($webform);
262266
// If allowed users is non-empty and user is not in there deny access.
263267
if (!empty($allowedUsers) && !isset($allowedUsers[$user->id()])) {
264268
return -1;
265269
}
266270
}
271+
267272
return NULL;
268273
}
269274

0 commit comments

Comments
 (0)