Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docblock incomplete in field_read_instances(). #6769

Open
laryn opened this issue Dec 4, 2024 · 1 comment
Open

Docblock incomplete in field_read_instances(). #6769

laryn opened this issue Dec 4, 2024 · 1 comment

Comments

@laryn
Copy link
Contributor

laryn commented Dec 4, 2024

Description of the bug

I ran into a warning in a contrib module:

Warning: Array to string conversion in field_read_instances() (line 757 of /var/www/html/backdrop/core/modules/field/field.crud.inc).

This led me to look into field_read_instances, where the contrib module was sending $params['field_name'] as an array of field names. The code seems to expect a string for this optional property -- but looking up to the docblock for verification, I don't see this property listed:

/**
 * Reads in field instances that match an array of conditions.
 *
 * @param $param
 *   An array of properties to use in selecting a field instance. Supported
 *   properties include:
 *   - entity_type: The entity type to which to limit instances.
 *   - bundle: The bundle type within the entity to which instances should be
 *     limited. If specified, an entity_type must be specified as well.
 * @param $include_additional
 *   The default behavior of this function is to not return field
 *   instances that have been marked deleted, or whose field is inactive.
 *   Setting $include_additional['include_inactive'] or
 *   $include_additional['include_deleted'] to TRUE will override this
 *   behavior.
 * @return
 *   An array of instances matching the arguments.
 */
@laryn
Copy link
Contributor Author

laryn commented Dec 4, 2024

Interestingly I just ran across this again in a different module. It looks like D7 allowed an array of values for field_name -- should we change the function to allow for that, or document the change to only allow a single value for field_name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant