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

Document changes to field_read_fields() #6768

Open
NormPlum opened this issue Dec 2, 2024 · 1 comment
Open

Document changes to field_read_fields() #6768

NormPlum opened this issue Dec 2, 2024 · 1 comment

Comments

@NormPlum
Copy link

NormPlum commented Dec 2, 2024

The field_read_fields() function has changed since Drupal 7. I just ported a module that used this function, and it didn't work due to changes in the information provided to and from it.

For example, the D7 code was:

foreach (field_read_fields(array('type' => 'entityreference', 'entity_type' => $instance['entity_type'])) as $field_name => $field_info) {
  $er_fields[$field_name] = $field_name;
}

whereas I had to change it to:

foreach (field_read_fields(array('type' => 'entityreference')) as $field_name => $field_info) {
  if ($field_info['settings']['target_type'] == 'node') {
    $er_fields[$field_name] = $field_name;
  }
}

as passing in 'entity_type' no longer works.
There are other changes too. The D7 documentation says:

Additionally, conditions on the 'entity_type' and 'bundle' columns from the 'field_config_instance' table are supported (select fields having an instance on a given bundle).

But this seems to no longer be the case.

I think the changes to this function need to be documented, as I couldn't find any change records for it: https://docs.backdropcms.org/change-records?keys=field_read_fields&field_impacts_value=All

@laryn
Copy link
Contributor

laryn commented Dec 4, 2024

@NormPlum Thanks for filing this -- I ran across something field_read_* related just recently as well and it's also a change that needs to be documented. I'm guessing these changes came in with config management way back when...

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

2 participants