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.

CommentFileSizeAuthor
#2 964400-hacky-file_file_download-fix.diff954 bytesChrisRL

Comments

pwolanin’s picture

Version: 7.0-beta2 » 7.x-dev

The end of your comment doesn't make sense - perhaps you mean when then entity_id does not match the revision_id?

ChrisRL’s picture

StatusFileSize
new954 bytes

Yes, 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.

carlos8f’s picture

Status: Active » Closed (duplicate)