file_get_file_references does not return correct results when using $field param

Created on 19 May 2023, over 1 year ago

Problem/Motivation

file_get_file_references has a parameter $field which is described as:

 @param \Drupal\Core\Field\FieldDefinitionInterface|null $field
    (optional) A field definition to be used for this check. If given,
    limits the reference check to the given field. Defaults to NULL.

When passing in a field definition the logic within the fuction is actually comparing this field to field storage definitions instead of the field instances.

Passing in a storage definition is not permitted by the type hint - but removing this type hint and passing in field storage instead of field config does return the correct response.

Steps to reproduce

See patch

Proposed resolution

In #3035352 it is proposed to deprecate this function and move to a service.

I have looked through core and there are no usages on this param.

I have search in contrib and was unable to find any attempt to use a non NULL value for this param.

Rather than fix, it might be an option to just drop this param as part of #3035352

Remaining tasks

  1. Agree on approach

User interface changes

N/a

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
File system 

Last updated 2 days ago

Created by

🇳🇿New Zealand ericgsmith

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

Comments & Activities

Production build 0.71.5 2024