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?

Issue fork drupal-3207669

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

klausi created an issue. See original summary.

klausi’s picture

Status: Active » Needs review
StatusFileSize
new944 bytes

Patch.

apaderno made their first commit to this issue’s fork.

avpaderno’s picture

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.