Skip to content

Commit

Permalink
Add access check to entity queries
Browse files Browse the repository at this point in the history
In drupal 10, if you don't explicitly set access check to true or
false, it throws a deprecation error.

This should probably have been set to FALSE anyway. (The previous,
default behaviour was TRUE).
  • Loading branch information
Andy Foster committed Nov 8, 2023
1 parent 7bc9ad3 commit 2d0dbb2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,10 @@
"./vendor/bin/phpcs --standard=Drupal --ignore=*.md,vendor --extensions=php,module,inc,install,test,profile,theme,css,info .",
"./vendor/bin/phpcpd --names='*.module,*.inc,*.test,*.php' --exclude=vendor ."
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
3 changes: 3 additions & 0 deletions src/EventDownloadService.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public function libcalEventToNode(array $events)
public function queryEventNode($event_id)
{
$query = \Drupal::entityQuery('node');
$query->accessCheck(FALSE);
$query->condition('status', 1);
$query->condition('type', 'event');
$query->condition('field_libcal_id', $event_id);
Expand Down Expand Up @@ -136,6 +137,7 @@ public function updatePastFieldEventNode($config)
// Begin constructing the query
// All event types with a start date in the past
$query = \Drupal::entityQuery('node');
$query->accessCheck(FALSE);
$query->condition('type', 'event');
$query->condition('field_start_date', $now, '<');

Expand Down Expand Up @@ -178,6 +180,7 @@ public function deleteEventNodes($events) {

// Get all future events
$query = \Drupal::entityQuery('node');
$query->accessCheck(FALSE);
$query->condition('type', 'event');
$query->condition('field_start_date', $now, '>=');
$nids = $query->execute();
Expand Down

0 comments on commit 2d0dbb2

Please sign in to comment.