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.
Updated: Comment #57
Problem/Motivation
The array $display passed to FieldInfo::prepareInstanceDisplay() contain the array key ['type] but no value (NULL). The following code fail to set the default_formatter.
$display += array(
'label' => 'above',
'type' => $field_type_info['default_formatter'],
'settings' => array(),
'weight' => 0,
);
And you get
Undefined index: module in prepareInstanceDisplay() (line 610 of modules/field/field.info.class.inc).
all over the place.
Proposed resolution
Test and set the array value outside where the default values are populated.
$display += array(
'label' => 'above',
'settings' => array(),
'weight' => 0,
);
if (empty($display['type'])) {
$display['type'] = $field_type_info['default_formatter'];
}
Remaining tasks
None
User interface changes
None
API changes
None
Original report by @mori
Notice: Undefined index: module in _field_info_prepare_instance_display() (line 346 of /Applications/MAMP/htdocs/drupal-7.0-beta/modules/field/field.info.inc).
* Notice: Undefined index: module in _field_info_prepare_instance_display() (line 346 of /Applications/MAMP/htdocs/drupal-7.0-beta/modules/field/field.info.inc).
* Notice: Undefined index: module in _field_info_prepare_instance_display() (line 346 of /Applications/MAMP/htdocs/drupal-7.0-beta/modules/field/field.info.inc).
* Notice: Undefined index: node_reference in field_ui_field_overview_form() (line 356 of /Applications/MAMP/htdocs/drupal-7.0-beta/modules/field_ui/field_ui.admin.inc).
* Notice: Undefined index: node_reference in field_ui_existing_field_options() (line 1439 of /Applications/MAMP/htdocs/drupal-7.0-beta/modules/field_ui/field_ui.admin.inc).
Comment | File | Size | Author |
---|---|---|---|
#82 | field-undefined-index-module-955658-81.patch | 506 bytes | ethomas08 |
Comments
Comment #1
yched CreditAttribution: yched commentedMore info is needed before anything can be investigated.
An error in field_ui_field_overview_form() means you get that error while viewing some "Manage fields" page.
- for which node type ?
- what are the fields in this node type ? and their respective field types ?
- is there any field module that was enabled at some point and then disabled (maybe node_reference.module ?)
- Is that a fresh D7 install or an upgraded D6 site ?
Comment #2
drupal a11y CreditAttribution: drupal a11y commentedHope this helps you:
PHP-Version: 5.2.13
from the log file:
Type php
Date Saturday, October 30, 2010 - 11:59
User admin
Location http://mori.drupal7.dev/admin/reports/fields?render=overlay
Referrer http://mori.drupal7.dev/
Message Notice: Undefined index: node_reference in field_ui_fields_list() (line 24 of /Applications/MAMP/htdocs/drupal-7.0-beta/modules/field_ui/field_ui.admin.inc).
Severity notice
Type php
Date Saturday, October 30, 2010 - 08:24
User admin
Location http://mori.drupal7.dev/admin/config/development/performance
Referrer http://mori.drupal7.dev/admin/config/development/performance
Message Notice: Undefined index: module in _field_info_prepare_instance_display() (line 346 of /Applications/MAMP/htdocs/drupal-7.0-beta/modules/field/field.info.inc).
Type php
Date Friday, October 29, 2010 - 11:56
User admin
Location http://mori.drupal7.dev/admin/structure/types/manage/mediafront-test/fie...
Referrer http://mori.drupal7.dev/admin/structure/types/manage/mediafront-test/fie...
Message Notice: Undefined index: module in _field_info_prepare_instance_display() (line 346 of /Applications/MAMP/htdocs/drupal-7.0-beta/modules/field/field.info.inc).
Type php
Date Friday, October 29, 2010 - 11:53
User admin
Location http://mori.drupal7.dev/admin/structure/types/manage/mediafront-test/fie...
Referrer http://mori.drupal7.dev/admin/structure/types/manage/mediafront-test/fie...
Message Notice: Undefined index: module in _field_info_prepare_instance_display() (line 346 of /Applications/MAMP/htdocs/drupal-7.0-beta/modules/field/field.info.inc).
Type php
Date Friday, October 29, 2010 - 11:55
User admin
Location http://mori.drupal7.dev/admin/structure/types/manage/mediafront-test/fie...
Referrer http://mori.drupal7.dev/admin/structure/types/manage/mediafront-test/fie...
Message Notice: Undefined index: module in _field_info_prepare_instance_display() (line 346 of /Applications/MAMP/htdocs/drupal-7.0-beta/modules/field/field.info.inc).
>An error in field_ui_field_overview_form() means you get that error while viewing some "Manage fields" page.
>- for which node type ?
An own created node type.
>- what are the fields in this node type ? and their respective field types ?
Label ... Name Field Widget Operations
mediafrontplayer ... field_mediafrontplayer Media Player Media Player edit delete
Multimedia-Asset ... field_media_asset Multimedia asset Media file selector edit delete
Title ... title Node module element
Body ... body Long text and summary Text area with a summary edit delete
Introduction ... field_file_video File File edit delete
Image Upload ... field_file_image Image Image edit delete
>- is there any field module that was enabled at some point and then disabled (maybe node_reference.module ?) Yes. But I can not say which ones cause I am testing a lot at the moment.
>- Is that a fresh D7 install or an upgraded D6 site ?
Fresh and clean d7b2 installation with additional modules.
All in all I currently made some module updates and was NOT able to reproduce this error.
I´ll be testing more and will inform you with details asap. Meanwhile put this issue on hold.
Comment #3
drupal a11y CreditAttribution: drupal a11y commentedThink this is fixed. Could not reproduce the error.
Comment #4
sslam CreditAttribution: sslam commentedi have the same error
Comment #5
Refineo CreditAttribution: Refineo commentedI get this notice message
* when running update.php
* after running update.php, the message shows together with "No pending updates." .
Drupal 7.12
Comment #6
filijonka CreditAttribution: filijonka commentedhey
read #1 and see #2 and report back with more information
Comment #7
Refineo CreditAttribution: Refineo commentedHere is more details:
Notice: Undefined index: module in _field_info_prepare_instance_display() (line 354 of /***/modules/field/field.info.inc).
Home » Administration » Structure » Content types » Basic page
standard fields used:
Title title Node module element
Body body Long text and summary Text area with a summary edit delete
URL path settings path Path module form elements
URL redirects redirect Redirect module form elements
enabled field types:
boolean
computed (http://drupal.org/project/computed_field)
date (http://drupal.org/project/date)
date (ISO format)
date (UNIX timestamp)
decimal
email (http://drupal.org/project/email)
file
fivestar rating (http://drupal.org/project/fivestar)
float
group audience
image
integer
link
list (float)
list (integer)
list (text)
location
long text
long text and summary
node reference
node reference count
serial
term reference
text
user reference
views (http://drupal.org/project/views_field)
... (Array, 12 elements)
11: _field_info_prepare_instance_display() (Array, 2 elements)
file (String, 32 characters ) modules/field/field.info.inc:354
args (Array, 2 elements)
0 (Array, 17 elements)
translatable (String, 1 characters ) 0
entity_types (Array, 0 elements)
settings (Array, 3 elements)
storage (Array, 5 elements)
foreign keys (Array, 1 element)
indexes (Array, 1 element)
id (String, 2 characters ) 57
field_permissions (Array, 1 element)
field_name (String, 11 characters ) field_venue
type (String, 14 characters ) node_reference
module (String, 14 characters ) node_reference
active (String, 1 characters ) 1
locked (String, 1 characters ) 0
cardinality (String, 1 characters ) 1
deleted (String, 1 characters ) 0
columns (Array, 1 element)
bundles (Array, 0 elements)
1 (Array, 5 elements)
label (String, 6 characters ) hidden
type (NULL)
weight (String, 1 characters ) 5
settings (Array, 0 elements)
module (NULL)
Drupal 7.12 (upgrade from Drupal 7.11)
PHP 5.3.8
Comment #8
filijonka CreditAttribution: filijonka commentedThe error says that you have a field named field_venue of type node referens, have you added that field to the basic content type or another content type? If another one, is there any other added fields to that type?
What are the display settings for this field?
Comment #9
Refineo CreditAttribution: Refineo commentedI have added this to my custom content type - Event
Display settings:
In this case "Venue" field is displayed as a rendered Teaser of another (referenced) custom content type Venue
Comment #10
filijonka CreditAttribution: filijonka commentedComment #11
alayham CreditAttribution: alayham commentedI get lots of this (around 30 or more) on each admin page , less on normal page views.
Notice: Undefined index: module in _field_info_prepare_instance_display() (line 354 of /***/modules/field/field.info.inc).
the site is upgraded from D6 to D7.12, all fields migrated.
I could not notice anything upnormal in field_config or field_config_instance
Comment #12
Refineo CreditAttribution: Refineo commentedI got this after mirroring one D7.12 site to another D7.12 site with drush and features.
Notice: Undefined index: module in _field_info_prepare_instance_display() (line 354 of /***/modules/field/field.info.inc).
Comment #13
filijonka CreditAttribution: filijonka commentedwe really need steps from you guys to be able to reproduce this and thereby being able to debug it.
try to install a clean instalaltion of a D7 and see if you can find the error. adding your contributed modules one by one to see if anyone of thos creating this error.
Comment #14
alayham CreditAttribution: alayham commentedUnable to reproduce on a new installation. It happened to me on an ungrade, and I tested the upgrade twice to get the same result.
Nothing seems to be wrong, except for this warning, I don't know what I am missing.
Could this be related to the data, not to the structure?
Comment #15
filijonka CreditAttribution: filijonka commented@refineo
when using features, what were you exporting?
Comment #16
Refineo CreditAttribution: Refineo commentedI exported most of the configuration including box*, ds* (display suite), elysia_cron*, feeds*, field*, filter*, flag*, image*, menu*, og*, profile*, rules*, taxonomy*, user*, uuid*, variables*, views*
but it was enough to export variables* only to get to the message:
I am trying to narrow this even further.
Comment #17
Refineo CreditAttribution: Refineo commentedAd #16
Notice messages appear only when using Features module with or without Strongarm
I could reduce this scenario to any variable exported to a feature using the Features and Strongarm modules.
Enabling (or disabling) any exported feature in the destination Drupal instance always causes the notice messages on page: /***/admin/structure/features
Refreshing page /***/admin/structure/features causes notice messages to disappear.
The same notice message occurs when I try to enable any other feature (not Strongarm-related).
Another notice messages related to field_ui module
I receive a lot of notices in /***/admin/reports/fields , each for different missing field but I think this is another issue:
Cannot directly reproduce notices reported in #1 #2
I cannot reproduce previously reported notices in
/***/admin/config/development/performance
or any other admin path (other then related to features module).
Summary
I would say this is more the Features 7.x-1.x-dev module issue then the Drupal core issue.
I also think issues reported from #4 are a bit different then those reported in #1 and in #2.
Comment #18
filijonka CreditAttribution: filijonka commentedgood work @refineo. moving this issue over to features module.
Comment #19
Refineo CreditAttribution: Refineo commentedI have debuged the error in #17 and found that the reason for the error message
Notice: Undefined index: module in _field_info_prepare_instance_display() (line 354 of /***/modules/field/field.info.inc).
was in handling of field_info_formatter_types($display['type'])
Source: API information.
The case when $formatter_type is omitted, was not handled in the code of function _field_info_prepare_instance_display($field, $display).
When the array of all display types is returned as $formatter_type, there is no $formatter_type['module'] available.
I think the field system should check $formatter_type[$field_type['default_formatter']] in this case.
I provide a patch to D7 dev field to handle this in Core under /modules/field/field.info.inc.
Please review.
Comment #21
Refineo CreditAttribution: Refineo commentedCorrected #19 patch formatting. Let's try again.
Comment #23
filijonka CreditAttribution: filijonka commentedok so moving this to 8.x so we get it solved there,
@refineo do oyu think you can give us some steps on how to reproduce this error
good work btw finding this.
Comment #24
rfay[Removed] - Sorry, I meant to post this in #1528942: FAILED: [[SimpleTest]]: [MySQL] Invalid patch format ?
Comment #25
Refineo CreditAttribution: Refineo commentedOnce again, now converted EOL differently...
Comment #27
Refineo CreditAttribution: Refineo commentedSo should this be 7.x or 8.x ?
I believe you start with 8.x and then move down to 7.x .
I am testing it a bit further and trying to provide the right patch file.
Comment #28
Refineo CreditAttribution: Refineo commentedI should have tested the patch with git apply --stat --check *.patch first...
Comment #30
Refineo CreditAttribution: Refineo commentedI try 7.x-dev first...
Comment #31
Refineo CreditAttribution: Refineo commented#28: field-undefined-index-module-955658-28.patch queued for re-testing.
Comment #32
Refineo CreditAttribution: Refineo commentedEventually tested the patch from comment #28 successfully in D7 so I move this to D8.
Comment #33
Refineo CreditAttribution: Refineo commentedHere is the new patch for 8.x-dev tested with git apply --stat --check *.patch .
Comment #35
Refineo CreditAttribution: Refineo commentedOnce again with a different path...
Comment #37
Refineo CreditAttribution: Refineo commentedHmm... strange. I try once again this time with diff --git a/modules/field/field.info.inc b/modules/field/field.info.inc
Comment #39
yched CreditAttribution: yched commentedre @refineo #19 :
Thanks for the detective work !
field_info_formatter_types($display['type']) returning the array of all formatter types because $display['type'] is empty would be a bug in external code :
- either the incoming $display param has $display['type'] = '', which would be a bug in the calling code,
- either $display['type'] = 'some_unknown_formatter' *and* the field type has no 'default_formatter' property, which would be a bug in the field type module.
I'm not OK with adding
I'm ok with better proofing against the 1st case by replacing
(only fills in 'type' if the property is absent from $param) with :
$display += array(
'label' => 'above',
'settings' => array(),
'weight' => 0,
);
if (empty($display['type'])) {
$display['type'] = $field_type['default_formatter'];
}
Comment #40
Refineo CreditAttribution: Refineo commentedOK yched I will prepare a new patch for this now.
Comment #41
Refineo CreditAttribution: Refineo commentedHere is the new D8 patch based on yched's comment in #39.
Comment #42
emorency CreditAttribution: emorency commentedNot sure where to post this patch for the current D7 version... Added a check for $display['module'] when null following suggestion from here http://drupal.org/node/1001060#comment-6341700
Comment #45
filijonka CreditAttribution: filijonka commentedif I get this right #41 is a patch for D8, we need to make a test for that before we make a patch for D7 (#43?).
So based on #42 I set this to needs review.
/Peter
Comment #46
carrierawks CreditAttribution: carrierawks commentedAny news on this?
Comment #47
vregouby CreditAttribution: vregouby commentedI get the issue, is there a patch for D7 ?
Comment #48
oadaeh CreditAttribution: oadaeh commentedSince field formatters were converted to plugins, is this still a problem in D8?
http://drupalcode.org/project/drupal.git/commit/b149df70af393eecd8b66839...
If not, we can move this to D7 and just work on that fix.
Comment #49
dswier CreditAttribution: dswier commentedI had been using the patch in #28, but after the 7.22 update the problem is now in field.info.class.inc. Since I was getting really annoyed with all the errors in my log, I figured out what changes needed to be made to field.info.class.inc to have the same effect as the patch from #28. Attached is an updated version of the patch for D7.
Comment #50
oadaeh CreditAttribution: oadaeh commentedI'm sorry to say this, but your code style will not be accepted as it stands. At least two changes need to be made:
The "else {" should be on the next line down from the closing brace.
http://drupal.org/coding-standards#controlstruct
The comment should be on the next line down from the closing brace.
http://drupal.org/node/1354#inline
Also, I did not test the code for validity, I only read through the patch.
Comment #51
oadaeh CreditAttribution: oadaeh commentedI forgot to update the Status.
Comment #52
dswier CreditAttribution: dswier commentedThanks for pointing out those mistakes. Here is another attempt that should be correct as far as code style goes.
Comment #53
JeroenTHi,
I installed entity API and inline entity form. When I'm watching the "Manage fields" page of any node type I have the following errors:
Notice: Undefined index: module in FieldInfo->prepareInstanceWidget() (line 575 of /***/modules/field/field.info.class.inc).
Notice: Undefined index: module in FieldInfo->prepareInstanceDisplay() (line 610 of /***/modules/field/field.info.class.inc).
Notice: Undefined index: entityreference in field_ui_existing_field_options() (line 1545 of /***/modules/field_ui/field_ui.admin.inc).
Even after applying patch #52.
Edit: Sorry! ignore this post. There was something else wrong!
Comment #54
dswier CreditAttribution: dswier commentedSo since 7.23 was released, I had a chance to see if my patch still applies. It still applies and fixes the errors. Can anybody else try it out and confirm that it works?
Comment #55
boran CreditAttribution: boran commentedPatch #52 worked for me
Comment #56
steinmb CreditAttribution: steinmb commentedI think we need a Issue summary.
Comment #57
steinmb CreditAttribution: steinmb commentedUpdated the issue summary and submitted a new patch. Do this issue really need tests?
Comment #58
steinmb CreditAttribution: steinmb commentedComment #59
steinmb CreditAttribution: steinmb commentedComment #60
steinmb CreditAttribution: steinmb commentedComment #61
Bevan CreditAttribution: Bevan commentedPatch solves the issue and meets coding standards. An inline comment explaining why it is not in the previous
+= array(
would improve it.Comment #62
hawkeye.twolfPatch is RTBC, let's get this committed.
I'll update the issue summary as well, but here's a recap:
In PHP array union, the first item takes precedence. So
array('foo' => NULL) + array('foo' => 'bar')
results inarray('foo' => NULL)
.So, in our case, if
$display
has$type => NULL
or some other value that evaluates to FALSE when cast to boolean, it causesfield_info_formatter_types()
to return all formatter types, which is not expected byprepareInstanceDisplay()
.Comment #63
geerlingguy CreditAttribution: geerlingguy commentedIs this RTBC, or does it still need tests ('Needs tests' tag still present)?
Comment #64
David_Rothstein CreditAttribution: David_Rothstein commentedI don't see any resolution to the question about whether or not this is still an issue in Drupal 8 (see #48)?
Tests would at least be a really good idea here, since it's not obvious from the code why the change matters and this is therefore something that could very easily be reverted by mistake later on.
Comment #65
yched CreditAttribution: yched commentedThis area was completely reshuffled in D8, that's irrelevant there.
Comment #66
Aurochs CreditAttribution: Aurochs commentedI hv really aweful number of such mistakes everywhere - in media files fields management, media filed display settings, module saving caused that as well.
Comment #67
Bevan CreditAttribution: Bevan commentedI am moving this back to Drupal 7 since it is irrelevant for Drupal 8 and not likely to ever get fixed if it is in that queue.
I traced this back to some fields that were incorrectly configured to display in a custom display mode (via display suite). In these examples the field in question is
field_headline_image
and is a field fortaxonomy_term
entities in theneutral
vocabulary. The display mode isanonymous_modal
. These are the settings as exported by features toarchetype_article.features.field_instance.inc
.The PHP warnings went away when I changed this to:
Features did not notice the change. A revert was not required. I suspect this is the result of adding a custom display mode and updating feature packages without saving the display configuration UI or some other such combination of configuration steps. I do not know what the combination is.
It is also unclear to me if the bug is in Core, Features or Display suite. I do not think the bug is in the field implementations because there were four fields affected in the site where I fixed this and they were of a range of different types; text, long text and image.
However they were all in the same feature package and for the
anonymous_modal
display mode fortaxonomy_term
entities of theneutral
vocabulary.Hopefully this helps others.
Comment #68
steinmb CreditAttribution: steinmb commentedHi Bevan :)
I have seen those 'module' => 'NULL' floating around on some sites. Tried once to trace down what it is actually used for and how it works, but gave up. Anyone know?
Some of these, I think, comes from custom fields/formatters defined in 3-part modules that was incorrectly removed from the system. By incorrect I mean. The field/formatter was not first removed from the entity (removing any data from the db) and/or the module hook_uninstall() was not run. #39 list some problems.
In my mind, the best solution would be to provide proper drupal warning instead of letting PHP throw this array warning, and having a supporting documentation on how/where to look to clean them out. The document would never be a catch all (I think) but could at least point users in the right direction.
Comment #69
Nicolas Bouteille CreditAttribution: Nicolas Bouteille commentedIf i apply patch #57 manually, the Notice error goes away but now my whole page won't display. H1 is now "Error" and I have two new error messages displaying :
Notice : Undefined index: taxonomy_term in taxonomy_field_formatter_view() (line 1601 [pathToRoot]/modules/taxonomy/taxonomy.module).
EntityMalformedException : Missing bundle property on entity of type taxonomy_term. in entity_extract_ids() (line 7729 [pathToRoot]/includes/common.inc).
Which lead me here: https://www.drupal.org/node/2128265 and when I apply patch #17 from there is all works fine.
Comment #70
333martine CreditAttribution: 333martine commentedRunning update.php ,#5, helped for me, working with D7.
Thanks.
Comment #71
Louis Delacretaz CreditAttribution: Louis Delacretaz commentedUsing features to creating content types produced this error for me in drupal 7.34
Fixed by applying the patch #57
cheers
Comment #72
priyankprajapati CreditAttribution: priyankprajapati commentedI used drupal 7.36. When i disable the commerce license module that time I face this error.
Notice: Undefined index: module in FieldInfo->prepareInstanceDisplay() (line 626 of C:\xampp\htdocs\aptech_video\modules\field\field.info.class.inc).
so how can i solve this error ?
Comment #73
steinmb CreditAttribution: steinmb commentedNothing about this is critical.
Comment #74
moritzz CreditAttribution: moritzz commentedThis issue still occurs in D7-7.39. I'd call it 'Critical' due to the fact that there might be few people with the guts to patch core.
Comment #75
joelpittet#57 solved a big fatal with some dynamic fields coming from commerce_discount.
Comment #76
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedCommitted to 7.x - thanks!
I'm a little iffy on what exactly causes this bug and whether we're really just committing a workaround, but it has buy-in from a field system maintainer and generally seems useful, and it also does seem consistent with the code that already exists further down ("Fall back to default formatter if formatter type is not available"), since clearly if the type is FALSE or NULL or something, it's not a real formatter either.
Comment #78
drupal a11y CreditAttribution: drupal a11y as a volunteer commentedThanks to all helpers for the great work!
Comment #80
mmarinescu CreditAttribution: mmarinescu commentedHey guys, I'm getting the same error too but since I'm new to Drupal, can't figure out how to fix it from this post. Could you please help me? Where should I go to write the proposed solution? In which file? Working with drupal 7.41.
Thanks in advance!
Please note I'm not using drush.
Comment #81
crutch CreditAttribution: crutch commentedCurrently 7.41. Is this in 7.42 or 7.43 or do we still need to patch? Getting big load of these errors now.
Comment #82
ethomas08 CreditAttribution: ethomas08 commentedCreated a patch for drupal core 7.91. The undefined array key notice is triggered when editing a panel field.