Hello I have encountered an error in the function field_extra_fields. The problem is on the line 398 of file field.module:

 function field_extra_fields($bundle_name)
  .
  .
  .
$extra = module_invoke_all('field_extra_fields', $bundle);

$bundle is passed to the function but it only gets the name of the $bundle examples(node, file, user). When for example I add extra fields a particular node type can not add that I have no way of identifying the type of content. I think what he wants to spend is $ bundle_label. Additionally $bundle_label variable name in foreach does not make sense.

CommentFileSizeAuthor
#3 field_extra_fields-665878-3.patch11.64 KByched

Comments

fastangel’s picture

An example of the bug is in the poll module.

function poll_field_extra_fields($bundle) {
  $extra = array();

  if ($bundle == 'poll') {                                       //This never happens
    $extra['choice_wrapper'] = array(
      'label' => t('Poll choices'),
      'description' => t('Poll module choices.'),
      'weight' => -4,
    );
    $extra['settings'] = array(
      'label' => t('Poll settings'),
      'description' => t('Poll module settings.'),
      'weight' => -3,
    );
  }

  return $extra;
}

yched’s picture

True, that hook needs to receive $obj_type as well, as its first param. Leftover from #470242: Namespacing for bundle names.

yched’s picture

Status: Active » Needs review
StatusFileSize
new11.64 KB

Here's a patch:
- adds an $obj_type param to field_extra_fields(). Since #470242: Namespacing for bundle names, $bundle is not enough to uniquely qualify a bundle.
- refactors hook_field_extra_field() so that it is called once, instead of once per bundle.
- stores the extra field weights in a single variable, instead of one per bundle.
- moves the field_attach_extra_weight() API func from field.attach.inc to field.module. Nothing to do in 'attach'.

yched’s picture

Title: Problem bundles in field_extra_fields » field_extra_fields() broken - misses $obj_type param
Assigned: Unassigned » yched

clearer title + easier self tracking

dries’s picture

Priority: Critical » Normal
Status: Needs review » Needs work
Issue tags: +Needs tests

I committed this to CVS HEAD but it would be great to get confirmation from fastangel that this is fixed. We should also make sure this is covered by tests.

fastangel’s picture

Already fixed the problem. The hook is working properly. Además pasa los test sin problemas.

Thanks

sun’s picture

Issue tags: +Needs documentation

.

jhodgdon’s picture

Can you clarify sun why you tagged this issue with "needs documentation"? What needs to be documented?

sun’s picture

Issue tags: -Needs documentation

If I'm not mistaken, that same code has been changed some more times in the meantime, so documentation needs to happen elsewhere (or happened already).

Dries asked for tests though.

Tor Arne Thune’s picture

Title: field_extra_fields() broken - misses $obj_type param » (Tests needed) field_extra_fields() broken - misses $obj_type param
Version: 7.x-dev » 8.x-dev
Category: bug » task
Issue tags: +Needs backport to D7

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • Dries committed b12d812 on 8.3.x
    - Patch #665878 by yched: fixed field_extra_fields()
    
    

  • Dries committed b12d812 on 8.3.x
    - Patch #665878 by yched: fixed field_extra_fields()
    
    

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • Dries committed b12d812 on 8.4.x
    - Patch #665878 by yched: fixed field_extra_fields()
    
    

  • Dries committed b12d812 on 8.4.x
    - Patch #665878 by yched: fixed field_extra_fields()
    
    

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

  • Dries committed b12d812 on 9.1.x
    - Patch #665878 by yched: fixed field_extra_fields()
    
    

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Version: 11.x-dev » 8.0.x-dev
Assigned: yched » Unassigned
Issue summary: View changes
Status: Needs work » Closed (outdated)
Issue tags: -Needs backport to D7

This was committed in 2010 are remains open for tests. As far as I can tell tests were added in #2225629: Move hook_field_extra_fields() to the entity API.

I have updated credit and am closing this as fixed on the branch the commit was made.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.