Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Quote from modules/field/field.info.inc, lines 517 to 524:
/**
* Returns all field definitions.
*
* @return
* An array of field definitions, keyed by field name. Each field has an
* additional property, 'bundles', which is an array of all the bundles to
* which this field belongs keyed by entity type.
*/
But, if $info gets no values the return value was NULL, instead of array() because the $fields variable is created insite the foreach.
Comment | File | Size | Author |
---|---|---|---|
#6 | 863370-fields.patch | 662 bytes | andypost |
#4 | field-info-fields-863370-4.patch | 648 bytes | bjaspan |
field.info_.inc-wrong_return_on_field_info_fields.patch | 598 bytes | dmonroy | |
Comments
Comment #1
bjaspan CreditAttribution: bjaspan commentedLooks good. We could perhaps add a test for this but this is an extremely common code pattern in Drupal so I do not think it is necessary. But anyone wanting a bonus point could write one. Call field_info_fields(), delete all the fields it returns, and call it again, making sure it returns array() the second time.
Comment #3
dmonroy CreditAttribution: dmonroy commentedSteeps to reproduce the error i receive:
1. Install a clean Drupal 7 Alpha 6
2. Install Views (7.x-3.x-dev)
3. Go to views admin page
You will receive a warning on "..views/modules/field.views.inc" line 20, because we expect an array value, as explained on field_info_fields() documentation.
I think, this is not a views bug, because documentations say, the return value is an array.
Maybe it's something trivial, I did not like the warning shows
Comment #4
bjaspan CreditAttribution: bjaspan commentedThe patch did not apply because it was rolled from docroot/modules/field instead of docroot.
Comment #5
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #6
andypostShould be $fields not $field!!! field_info_fields()
Comment #7
dmonroy CreditAttribution: dmonroy commentedThanks to everyone, I'm new with cvs and patches.
Please commit the patch sent by andypost, because the right variable name is fields.
PS
I'm sorry for my (very bad) english.
Comment #8
dmitrig01 CreditAttribution: dmitrig01 commentedhttp://is.gd/3Sf9Z
Comment #9
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.