Drush not allowed to see nodes

Created on 16 October 2018, almost 7 years ago
Updated 25 September 2025, 10 days ago

We have a simple function that retrieves all nodes of content type "my_object" where the field "field_myobject_type" is filled with value "group" from our database, like so:

function my_object_get_groups() {
$query = my_object_get_base_query();
$query
->fieldCondition('field_myobject_type', 'value', 'group')
->propertyOrderBy('title', SORT_ASC);
return my_object_node_query_result($query);
}

If we call this with drush, we get no groups, and if we call it via the browser (logged in as admin, but not user 1), we get 2 groups, no problem.

Here's the same SQL query with nodeaccess and without, where myobject is an object type:
With nodeaccess:

SELECT field_data_field_myobject_type0.entity_type AS entity_type, field_data_field_myobject_type0.entity_id AS entity_id, field_data_field_myobject_type0.revision_id AS revision_id, field_data_field_myobject_type0.bundle AS bundle
FROM
field_data_field_myobject_type field_data_field_myobject_type0
INNER JOIN node node ON node.nid = field_data_field_myobject_type0.entity_id
WHERE (field_data_field_myobject_type0.field_myobject_type_value = 'group') AND (field_data_field_myobject_type0.deleted = '0') AND (node.status = '1') AND (field_data_field_myobject_type0.entity_type = 'node') AND (field_data_field_myobject_type0.bundle = 'myobject') AND(( ( EXISTS (SELECT na.nid AS nid
FROM
node_access na
WHERE (( (na.gid = '0') AND (na.realm = 'all') )OR( (na.gid = '1') AND (na.realm = 'nodeaccess_rid') )OR( (na.gid = '0') AND (na.realm = 'nodeaccess_uid') )OR( (na.gid = '0') AND (na.realm = 'nodeaccess_author') ))AND (na.grant_view >= '1') AND (field_data_field_myobject_type0.entity_id = na.nid) )) AND (field_data_field_myobject_type0.entity_type = 'node') )OR (field_data_field_myobject_type0.entity_type <> 'node') )
ORDER BY node.title ASC

via browser:

SELECT field_data_field_myobject_type0.entity_type AS entity_type, field_data_field_myobject_type0.entity_id AS entity_id, field_data_field_myobject_type0.revision_id AS revision_id, field_data_field_myobject_type0.bundle AS bundle
FROM
field_data_field_myobject_type field_data_field_myobject_type0
INNER JOIN node node ON node.nid = field_data_field_myobject_type0.entity_id
WHERE (field_data_field_myobject_type0.field_myobject_type_value = 'group') AND (field_data_field_myobject_type0.deleted = '0') AND (node.status = '1') AND (field_data_field_myobject_type0.entity_type = 'node') AND (field_data_field_myobject_type0.bundle = 'myobject')
ORDER BY node.title ASC

I tried to grant access to anonymous users for these nodes, and rebuilt the permissions, cleared both the regular and drush cache, but to no avail, it just won't work.

Does anyone have this same issue? Do you know a workaround/solution?

🐛 Bug report
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

🇳🇱Netherlands colorfulcoder

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024