Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I am trying to get all nodes in an update hook.
$query = \Drupal::entityQuery('node')
->condition('type', 'basic_article_page');
$nids = $query->execute();
is giving me only nids to a specific domain.
Maybe this is accidentally because those nodes are also the only one in "en" language code.
I can make it work when I put it in a MYMODULE_node_view hook but not in a MYMODULE_update_n hook.
Am I doing something wrong?
Greetings
Lars
Comments
Comment #2
Synflag CreditAttribution: Synflag commentedComment #3
agentrickardBy default, any EntityQuery or EntityField query is tagged with an entity access check which prevents displaying entities that should be restricted. This is a security feature and should not normally be bypassed.
If you are writing queries for an administrative interface, you can bypass that access check like so:
If using Views, you would check the Advanced option 'Disable SQL rewrites.'
This code may also need to be changed in
DomainContentController::getCount()
, since in earlier versions of Drupal that access tag had to be added manually.See https://www.drupal.org/node/1597378 and https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...
Comment #4
agentrickardI hadn't noticed that code change until now, and there is an error in the controller.
Comment #6
agentrickardCommitted. Thanks for the report!