Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Background import tasks handled by cron may run as anonymous user. Sometimes, the anonymous user is not allowed to query entities e.g when you use content access and restrict view to administrator role. In this case EFQ Finder won't return any result.
The solution is to run query as user allowed view to content. This patch adds field to choose which user to run the query with.
Comment | File | Size | Author |
---|---|---|---|
#5 | run-query-as-user-2531740-5.patch | 1.6 KB | mouhammed |
#4 | run-query-as-user-2531740-4.patch | 1.61 KB | mouhammed |
#1 | run-query-as-user-2531740-1.patch | 2.01 KB | mouhammed |
Comments
Comment #1
mouhammed CreditAttribution: mouhammed commentedComment #2
twistor CreditAttribution: twistor as a volunteer commentedWhy this change?
Can you give me an example of a query that is failing?
Comment #3
mouhammed CreditAttribution: mouhammed commentedExample :
We have to content type : Enterprise (Name) and Employe (Name, Enterprise). Every employe has an entity reference field to reference his enterprise.
Employe content type
Enterprise content type
Content access is enabled on Enterprise with this configuration :
Enterprise access control
We have create feeds to import all employe and set the entity reference field with the EFQ plugin.
When you run import from UI, all references are filled correctly but from cron, the query doesn't works. Because cron may run with anonymous user wich is not allowed to view content of type Enterprise.
Comment #4
mouhammed CreditAttribution: mouhammed commentedI removed accidental change on
Comment #5
mouhammed CreditAttribution: mouhammed commentedAvoid loading the user object twice.