Skip to content
Snippets Groups Projects

Access to Views argument lacks cacheable metadata

Open Dan Flanagan requested to merge issue/drupal-3091671:3091671-validate-user-has into 11.x
All threads resolved!
Files
4
@@ -2,6 +2,7 @@
@@ -2,6 +2,7 @@
namespace Drupal\views\Plugin\views\argument_validator;
namespace Drupal\views\Plugin\views\argument_validator;
 
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
@@ -215,8 +216,15 @@ public function validateArgument($argument) {
@@ -215,8 +216,15 @@ public function validateArgument($argument) {
*/
*/
protected function validateEntity(EntityInterface $entity) {
protected function validateEntity(EntityInterface $entity) {
// If access restricted by entity operation.
// If access restricted by entity operation.
if ($this->options['access'] && !$entity->access($this->options['operation'])) {
if ($this->options['access']) {
return FALSE;
$access = $entity->access($this->options['operation'], NULL, TRUE);
 
// Add runtime cacheability of the access result to the executable.
 
CacheableMetadata::createFromRenderArray($this->view->element)
 
->merge(CacheableMetadata::createFromObject($access))
 
->applyTo($this->view->element);
 
if (!$access->isAllowed()) {
 
return FALSE;
 
}
}
}
// If restricted by bundle.
// If restricted by bundle.
$bundles = $this->options['bundles'];
$bundles = $this->options['bundles'];
Loading