There is some kind of race condition when installing a module that adds fields, where core tries to assign weights to fields that have not yet been defined. For example, when enabling the simplenews module, I got the following notices:

  • Notice: Undefined index: email_plain in field_info_max_weight() (line 797 of /home/bobvin/Downloads/drupal/modules/field/field.info.inc).
  • Notice: Undefined index: email_html in field_info_max_weight() (line 797 of /home/bobvin/Downloads/drupal/modules/field/field.info.inc).
  • Notice: Undefined index: email_textalt in field_info_max_weight() (line 797 of /home/bobvin/Downloads/drupal/modules/field/field.info.inc).

Suggested one-line fix/workaround:


--- modules/field/field.info.inc
+++ modules/field/field.info.inc
@@ -793,7 +793,7 @@ function field_info_max_weight($entity_type, $bundle, $context) {
     if ($context == 'form') {
       $weights[] = $instance['widget']['weight'];
     }
-    else {
+    elsif (isset($instance['display'][$context]['weight'])) {
       $weights[] = $instance['display'][$context]['weight'];
     }
   }

Comments

pillarsdotnet’s picture

StatusFileSize
new490 bytes

Fixed typo

pfrenssen’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm this issue. I have reviewed and tested the patch. It solves the problem.

dries’s picture

Any reason why $instance['display'][$context]['weight'] is not set? Does it have to be set? Could be a bug elsewhere.

webchick’s picture

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

Let's add a test for this, and maybe that will point the way.

scotwith1t’s picture

sub

Tor Arne Thune’s picture

This bugged popped up when I installed and enabled Ubercart 7.x-3.0-beta1 Cart, Order, Product and Store in one go.

Notice: Undefined index: full in field_info_max_weight() (line 797 of /var/www/devia.org/modules/field/field.info.inc).

yched’s picture

Status: Needs work » Reviewed & tested by the community

The fix is correct. $instance['display'][$context]['weight'] might not be set if the view mode doesn't use custom display settings.

I'm not really sure this deserves a test (nor that it's easily testable), so tentatively setting back to RTBC

pillarsdotnet’s picture

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD (without test). It still had the 'Needs tests' tag.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

scottlozier’s picture

Patch fixed issue.

Vilas Boas’s picture

The bug is still active

Notice: Undefined index: email_html em field_info_max_weight() (linha 797 de /XXX/modules/field/field.info.inc).

JohanPirlouit’s picture

Priority: Minor » Normal
Status: Closed (fixed) » Needs review

Hi everyone,

I'm afraid that this bug may still be active: see Media Gallery 7.x install issue -> Undefined index: media_gallery_detail in field_info_max_weight(). If I'm wrong, I'll be sorry for this report ;-)

My Drupal version is 7.0 fresh install.
Some modules I installed and activated for my needs (and they work fine) before trying to install Media Gallery:
- IMCE 7.x-1.3
- CKEditor 7.x-1.1
- Webform 7.x-3.9

Modules I also installed and activated that are required for Media Gallery:
- Media 7.x-1.0-beta4
- Multiple forms 7.x-1.0-beta2
- Styles 7.x-2.0-alpha5
- ColorBox jQuery plugin 1.3.16

When I try to activate Media Gallery module (last release at this post time: 7.x-1.0-beta4) I receive those messages:

    * Notice: Undefined index: media_gallery_thumbnail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_thumbnail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_lightbox dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_lightbox dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_detail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_detail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_thumbnail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_thumbnail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_lightbox dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_lightbox dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_detail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_detail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_thumbnail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_thumbnail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_lightbox dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_lightbox dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_detail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_detail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_thumbnail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_thumbnail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_lightbox dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_lightbox dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_detail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_detail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_thumbnail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_thumbnail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_lightbox dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_lightbox dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_detail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_detail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_thumbnail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_thumbnail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_lightbox dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_lightbox dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_detail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).
    * Notice: Undefined index: media_gallery_detail dans field_info_max_weight() (ligne 797 dans /home/www/modules/field/field.info.inc).

Regards,
Johan

yched’s picture

Status: Needs review » Closed (fixed)

@JohanPirlouit : "My Drupal version is 7.0 fresh install."
The fix was committed after the 7.0 release. This means you'll need 7.x-dev (or 7.1 when it gets out).

JohanPirlouit’s picture

@yched > You're right! It works.

But, as it is a dev version (7.x-dev), I've got other issues ^^:
- When I edit my published gallery:

    * Notice: Undefined index: media_gallery_format dans locale_field_node_form_submit() (ligne 404 dans /home/www/modules/locale/locale.module).
    * Notice: Undefined index: media_gallery_lightbox_extras dans locale_field_node_form_submit() (ligne 404 dans /home/www/modules/locale/locale.module).
    * Notice: Undefined index: media_gallery_columns dans locale_field_node_form_submit() (ligne 404 dans /home/www/modules/locale/locale.module).
    * Notice: Undefined index: media_gallery_rows dans locale_field_node_form_submit() (ligne 404 dans /home/www/modules/locale/locale.module).
    * Notice: Undefined index: media_gallery_image_info_where dans locale_field_node_form_submit() (ligne 404 dans /home/www/modules/locale/locale.module).
    * Notice: Undefined index: media_gallery_allow_download dans locale_field_node_form_submit() (ligne 404 dans /home/www/modules/locale/locale.module).
    * Notice: Undefined index: media_gallery_expose_block dans locale_field_node_form_submit() (ligne 404 dans /home/www/modules/locale/locale.module).
    * Notice: Undefined index: media_gallery_block_columns dans locale_field_node_form_submit() (ligne 404 dans /home/www/modules/locale/locale.module).
    * Notice: Undefined index: media_gallery_block_rows dans locale_field_node_form_submit() (ligne 404 dans /home/www/modules/locale/locale.module).

- After I edit settings of the little Media Gallery block:

    * Notice: Undefined index: field dans field_widget_field() (ligne 521 dans /home/www/modules/field/field.form.inc).
    * Notice: Undefined index: instance dans field_widget_instance() (ligne 546 dans /home/www/modules/field/field.form.inc).
    * Warning: htmlspecialchars() expects parameter 1 to be string, array given dans check_plain() (ligne 1348 dans /home/www/includes/bootstrap.inc).

So I think field.info.inc is no more concerned ;-))... And I will investigate for other bugs that could have been reported about my new issues.

Regards,
Johan

spasebar’s picture

Hi everyone. I am getting this same error message, but I am not sure how to apply the patch. Where do I enter the code? I copy and pasted all of it in the field.info.inc file but get syntax errors. I thought it was suppose to be a one line fix? Sorry, as you can see I'm still an big noob. (Umm, is it even still cool to say noob anymore?) LOL

Thanks for the help guys if you would be so kind.

pfrenssen’s picture

The basic steps to apply a patch to Drupal core are:

  • Download the patch
  • Put it in the drupal root folder
  • Apply the patch

The patch can be applied using a variety of GUI tools and IDEs, but the easiest and fastest way is to do it is using the 'patch' command in terminal:

$ cd path/to/drupal/
$ wget http://drupal.org/files/issues/patchname.patch
$ patch -p0 < patchname.patch
$ rm patchname.patch

You can find more information about patching on Wikipedia or in the section about patching in the Drupal documentation.

spasebar’s picture

Umm, I'm still confused. How do I do this on a command line??? Where is terminal? Sorry. I really need step by step like total newbie instructions.

Oh, when I click on the link, it opens the file, should I just right click on it and save it, and then upload it to the root of my Drupal folder? If so, then I don't know how to apply it.

pillarsdotnet’s picture

@spasebar -- Dries already committed this patch. So you can either download the snapshot version of Drupal-7 from here, or just wait a couple of weeks until 7.1 comes out.

spasebar’s picture

Hi Pillar... oh okay, I think I might just wait. I'm kind of just experimenting with Drupal 7 and Ubercart. So I guess as long as I can kind of add products and theme, it should be okay, because we won't be going live just yet. So 7.1 should be coming out in the next couple of weeks?

Those errors don't seem to be affecting anything anyways right now as far as what I'm doing.

mercclear’s picture

Drupal 7.2
I just installed commerce shipment module with the same message
Notice: Undefined index: ................. in field_info_max_weight() (line 797 of ........ /modules/field/field.info.inc)

:-((

pillarsdotnet’s picture

Status: Closed (fixed) » Needs work
Tor Arne Thune’s picture

Version: 7.x-dev » 8.x-dev
Issue tags: +Needs backport to D7
adam_b’s picture

I'm getting this error with D7.8 after uninstalling the Media Gallery module: lots of instances such as
Notice: Undefined index: media_gallery_lightbox in field_extra_fields_get_display() (line 727 of /mnt/www/html/[site]/docroot/modules/field/field.module).
It went away by itself after a few minutes.

Has anything happened with this recently?

pillarsdotnet’s picture

Status: Needs work » Postponed (maintainer needs more info)

People who are still experiencing this problem need to document a way to make it happen, starting with a fresh install of Drupal 8.x-dev or Drupal 7.x-dev.

It is very hard to fix a problem that is neither documented nor easily duplicated.

summit’s picture

Hi,
Next to #1 I also have this bug on $extra fields (line 811). I had to change:

$weights[] = $extra['weight'];

To

 if(isset($extra['weight'])){ $weights[] = $extra['weight']; }
 

To remove this bug.

Latest Drupal 7 with Latest Commerce.
I am not able to build patches, but hopefully some of you guys can.
Thanks in advance
Greetings, Martijn

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 ee9cfb9 on 8.3.x
    - Patch #1001624 by pillarsdotnet: avoid 'Undefined index' notice in...

  • Dries committed ee9cfb9 on 8.3.x
    - Patch #1001624 by pillarsdotnet: avoid 'Undefined index' notice in...

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 ee9cfb9 on 8.4.x
    - Patch #1001624 by pillarsdotnet: avoid 'Undefined index' notice in...

  • Dries committed ee9cfb9 on 8.4.x
    - Patch #1001624 by pillarsdotnet: avoid 'Undefined index' notice in...

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 ee9cfb9 on 9.1.x
    - Patch #1001624 by pillarsdotnet: avoid 'Undefined index' notice in...

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.

pameeela’s picture

Issue summary: View changes
Issue tags: +Bug Smash Initiative

Thanks for reporting this issue. We rely on issue reports like this one to resolve bugs and improve Drupal core.

As part of the Bug Smash Initiative, we are triaging issues that are marked "Postponed (maintainer needs more info)".

Since there were no specific steps to reproduce the issue provided since the issue was postponed, I'm marking the issue "Closed (cannot reproduce)". If anyone can provide complete steps to reproduce the issue (starting from "Install Drupal core"), document those steps in the issue summary and set the issue status back to "Active".

Thanks!

pameeela’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)