file_get_file_references() can cause PHP out of memory errors

Created on 7 April 2021, about 3 years ago
Updated 18 April 2024, about 2 months ago

Problem/Motivation

If you have a managed file that is referenced by 200k entities then file_get_file_references() will cause PHP out of memory errors. It uses an unlimited entity field query and unlimited queries are bad.

Steps to reproduce

Create a managed file and reference it from 200k nodes.

Then invoke hook_file_download() for example from entity_metadata_file_access().

You get a PHP memory error.

Proposed resolution

Limit the query to just 1 result. This is not ideal and could cause problems, but in our use case a file is always used in the same field type. That has no access implications for us.

Remaining tasks

Review patch, come up with a better idea?

🐛 Bug report
Status

Needs review

Version

7.0 ⚰️

Component
File module 

Last updated 3 days ago

Created by

🇦🇹Austria klausi 🇦🇹 Vienna

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

Merge Requests

Comments & Activities

Not all content is available!

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

Production build 0.69.0 2024