When age=FIELD_LOAD_REVISION and field conditions are present, EntityFieldQuery is documented to return the revision id as the key, and file_get_file_references uses EntityFieldQuery exactly like this, so it gets revision ids. file_file_download uses file_get_file_references with age=FIELD_LOAD_REVISION, then proceeds to attempt to use the key (the revision id) as an id to entity_load.
I don't know if entity_load needs to support revision_ids, or file_get_file_references needs to be returning entity ids instead of revision ids, but this is causing private file downloads to not work properly when the node's entity_id doesn't match its entity_id.
Comments
Comment #1
pwolanin commentedThe end of your comment doesn't make sense - perhaps you mean when then entity_id does not match the revision_id?
Comment #2
ChrisRL commentedYes, apologies.
I've attached the patch I'm using, but I have no idea what the intended behavior is, and this does change the API (assuming file_get_file_references is intended as API and not just something the core modules use between each other). I'm fairly certain this is not a proper fix, but again, I don't know the intended behavior.
file_get_file_references could be changed back to default to FIELD_LOAD_REVISION, but I expect the function has the same use in other modules, and needs to provide easy access to entity ids.
Comment #3
carlos8f commentedMarking as duplicate of #992674: Private file download returns access denied.