The query in node_reference_field_prepare_view() gets the list of all published references.
However, sites would want to alter this query for different reasons using hook_query_alter(). In order to properly identify this query, could an 'id' be added as meta data, at the least?
Use case:
* Display all node references, including those that are unpublished, to all users
* But unpublished nodes on their own show 403 to normal users.
Attaching patch. I've also added the $field as a meta data as that could be useful.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | references-field_prepare_view_query-1256280-8.patch | 2.02 KB | girishmuraly |
| #4 | references-field_prepare_view_query-1256280.patch | 1.33 KB | yched |
| addMetaData_prepare-view-0.patch | 727 bytes | girishmuraly |
Comments
Comment #1
rickvug commentedSubscribe. This patch makes a lot of sense. I'm tempted to mark RTBC but I'll leave at needs review for now. #1139238: Manually alter the node reference list prior to query execution? could also use the query meta data so that node reference queries could be better targeted.
Comment #2
s_leu commentedclosing this as duplicate of #1139238: Manually alter the node reference list prior to query execution?
Comment #3
girishmuraly commentedI can't see how this is a duplicate. #1139238: Manually alter the node reference list prior to query execution? is relating to the query that produces references when using a node reference field in edit mode as far as I understand. This ticket is regarding altering the query that fetches referenced entities.
Swtiching status back for the patch in #0
Comment #4
yched commentedRerolled after #1354580: Unpublished nodes are not displayed, added similar code in user_reference, and committed the attached patch.
Thanks !
Comment #5
girishmuraly commented@yched, I am unable to apply the last patch (#4) onto 2.x branch or 2.0 release. Can you link to your commit please?
The base code seems different.
Rerolling #4
Comment #6
girishmuraly commentedForgot to change status.
Comment #8
girishmuraly commentedAlso forgot to attach patch for #5 duh!
Comment #9
yched commentedOops - #4 was the correct diff for 7.x-2.x after the commit in #1354580: Unpublished nodes are not displayed - I committed those two locally but forgot to push :-/.
So #4 was not applicable to any 7.x-2.x state available online.
Anyway. Pushed now, 7.x-2.x contains the fix. Sorry all.
Comment #10
girishmuraly commentedThanks @yched