// Collect weights for extra fields.
  foreach (field_info_extra_fields($entity_type, $bundle, $context) as $extra) {
    $weights[] = $extra['weight'];
  }

When $context is 'display', the result of field_info_extra_fields() is an array of display modes.

This causes a "Notice: Undefined index: weight" error when creating a field instance without weight to an entity that has a display extra field.

Comments

damien tournoud’s picture

Status: Active » Needs review
StatusFileSize
new702 bytes

We need something like this.

damien tournoud’s picture

Issue tags: +Needs backport to D7
msbrar’s picture

Version: 8.x-dev » 7.8

I am getting errors in field_info_max_weight while trying to do "Manage Fields" in content types which have multi lingual support set to "Enabled with translation". The manage fields page goes blank with error. The following code is causing problem (even when the $context variable is set to forms. the above patch did not work for me)

// Collect weights for extra fields.
foreach (field_info_extra_fields($entity_type, $bundle, $context) as $extra) {
$weights[] = $extra['weight'];
}

The $extra['weight'] returns an array in the above case while trying to "Manage Fields". I replaced the above code with the following code and it seems to work for me.

// Collect weights for extra fields.
foreach (field_info_extra_fields($entity_type, $bundle, $context) as $extra) {
$weight_var = $extra['weight'];
if(is_array($weight_var)) {
$weights = array_merge($weights, $weight_var);
}
else {
$weights[] = $weight_var;
}
}

i.e. merging in case the var $extra['weight'] is an array. I do not have any clue about how drupal works internally, but the above just seems to solve my problem. Can anybody please help me with the proper fix for this.

yched’s picture

Version: 7.8 » 8.x-dev
StatusFileSize
new1.13 KB

Wow, this stayed out of my radar for some time...

I see two errors in field_info_max_weight() :
- field_info_extra_fields() should be called with either 'form' or 'display', while field_info_max_weight() calls it with the name of a view mode.
- in case of 'display', as Damien pointed, field_info_extra_fields() returns weights indexed by view modes, and we need to get the weight of the right view mode.

Attached patch should fix this. @msbrar, does this fix your issue ?

Status: Needs review » Needs work

The last submitted patch, field_info_max_weight-1174100-4.patch, failed testing.

yched’s picture

Status: Needs work » Needs review
StatusFileSize
new1.31 KB

Small logic error in patch #4.

damien tournoud’s picture

This still looks wrong to me. Why are you calling field_info_extra_fields() repetitively for every instance?

Status: Needs review » Needs work

The last submitted patch, field_info_max_weight-1174100-6.patch, failed testing.

yched’s picture

Status: Needs work » Needs review
StatusFileSize
new818 bytes

Doh. This is starting to be embarrassing...

damien tournoud’s picture

Status: Needs review » Reviewed & tested by the community
chx’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

I am surprised two veterans getting to this point without a test.

yched’s picture

Status: Needs work » Needs review
StatusFileSize
new4.62 KB
new3.82 KB

Added tests.

msbrar’s picture

The above patches did not help me. I tested with drupal 7.8 earlier and am testing with 7.9 now. i tried different combinations but the problem still persists. Manage Fields presents a blank page if the content type has "enabled with translation" option selected for multilingual options.
However a workaround that is working for me is to disable the translation, add/manage fields and then turn it on again from the edit page.

yched’s picture

@msbrar : this is unrelated, the minor bug fixed here has never caused WSODs or fatal errors. Please open a new issue for the bug you describe.

Other than that, RTBC, anyone ? Before nov. 1st great patch-break storm ?

xjm’s picture

Status: Needs review » Needs work
Issue tags: +Novice

Patch-break storm has struck. :) So it will need to be rerolled. Tagging as novice for that task.

If you need help rerolling this patch, you can come to core office hours or ask in #drupal-gitsupport on IRC.

kathyh’s picture

Status: Needs work » Needs review
StatusFileSize
new4.67 KB

Rerolled per #15

xjm’s picture

Issue tags: -Novice

Thanks!

yched’s picture

kscheirer’s picture

Status: Needs review » Needs work

The last submitted patch, field_info_max_weight-1174100-16.patch, failed testing.

jhedstrom’s picture

Issue summary: View changes

Is this still an issue in 8.x?

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.

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.

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.

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

Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +Bug Smash Initiative

9 years ago it was asked if this is still an issue in Drupal 8+. There has been no reply confirming that which suggests that this is outdated. However, let's do one last check.

Is this still relevant?

Since we need more information to move forward with this issue, I am setting the status to Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

quietone’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

There hasn't been confirmation that this problem still exits since asking 5 moths ago. Therefor closing.

If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").

Thanks!