I got this error on the admin/help page, when the field module is enabled without any dependent modules.

In the field.module file, $items['items'] is filled in with a list of modules that implement field_info or field_widget_info and this array is given to the theme item_list function. In case of no module found, it generated a PHP notice and a PHP warning

How to reproduce on a minimal Drupal 8 install:

  • enable the help module
  • enable the field module
  • got to /admin/help
Files: 
CommentFileSizeAuthor
#19 2099261-19-field-help-test-use-test-module.patch1.67 KBmr.baileys
PASSED: [[SimpleTest]]: [MySQL] 58,954 pass(es).
[ View ]
#15 2099261-15-field-help-page.patch5.04 KBamateescu
PASSED: [[SimpleTest]]: [MySQL] 58,665 pass(es).
[ View ]
#8 2099261-7-field-help-page-TEST-ONLY.patch2.36 KBmr.baileys
FAILED: [[SimpleTest]]: [MySQL] 59,383 pass(es), 2 fail(s), and 2 exception(s).
[ View ]
#8 2099261-5-field-help-page.patch5.43 KBmr.baileys
PASSED: [[SimpleTest]]: [MySQL] 58,927 pass(es).
[ View ]
#5 2099261-5-field-help-page.patch5.43 KBmr.baileys
FAILED: [[SimpleTest]]: [MySQL] Setup environment: Test cancelled by admin prior to completion.
[ View ]
#2 field-notice_items_in_field_help-2099261-1.patch854 bytesJulienD
PASSED: [[SimpleTest]]: [MySQL] 58,887 pass(es).
[ View ]
#1 field-notice_items_in_field_help-2099261-1.patch854 bytesJulienD
PASSED: [[SimpleTest]]: [MySQL] 58,637 pass(es).
[ View ]
Screenshot- 2013-09-27 à 10.59.58.png156.31 KBJulienD

Comments

StatusFileSize
new854 bytes
PASSED: [[SimpleTest]]: [MySQL] 58,637 pass(es).
[ View ]

The $items variable is only used for the theme item_list function, so the items key is not useful in this case.

Status:Active» Needs review
StatusFileSize
new854 bytes
PASSED: [[SimpleTest]]: [MySQL] 58,887 pass(es).
[ View ]

The $item variable is only used for the item_list theme function, so the items key is not useful.

Status:Needs review» Reviewed & tested by the community

Looks good to me, thanks Julien :)

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

Could we get the steps to reproduce in the original post into a simple automated test for Help module? It's really odd that we don't have test coverage for this bunch of code.

Title:Notice: Undefined index: items in field_help()field_help() no longer lists field_type/widget modules and can throw undefined index notice.
Category:task» bug
Status:Needs work» Needs review
StatusFileSize
new5.43 KB
FAILED: [[SimpleTest]]: [MySQL] Setup environment: Test cancelled by admin prior to completion.
[ View ]

Wrote the tests for this, it turns out that the field help page is currently broken, since it still relies on hook_field_info(), which no longer exists ([#2064123]).

Changed field_help() to make use of the FieldTypePluginManager and WidgetPluginManager to fetch the list of modules to render, and added a couple of test cases (including a test for the notice reported in this issue).

Re-titling and classifying as bug to better reflect new situation.

Issue tags:-Needs tests

Removing the "Needs tests" tag.

Great! Can you please upload a test-only patch that will fail, thus confirming that the fixes are valid?

StatusFileSize
new5.43 KB
PASSED: [[SimpleTest]]: [MySQL] 58,927 pass(es).
[ View ]
new2.36 KB
FAILED: [[SimpleTest]]: [MySQL] 59,383 pass(es), 2 fail(s), and 2 exception(s).
[ View ]

Sure, test-only patch, followed by complete patch from #5

Status:Needs review» Needs work

The last submitted patch, 2099261-5-field-help-page.patch, failed testing.

Status:Needs work» Needs review

Hmmm. The failing test seems totally unrelated to this change, and it succeeds on my local machine, so requesting a retest.

#8: 2099261-5-field-help-page.patch queued for re-testing.

The actual help text for field_help() is outdated, but this is tackled in #2091319: Update hook_help for Field module.

Status:Needs review» Reviewed & tested by the community

Ok, patches fail/pass as expected, back to RTBC.

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

Patch no longer applies.

Status:Needs work» Reviewed & tested by the community
Issue tags:-Needs reroll
StatusFileSize
new5.04 KB
PASSED: [[SimpleTest]]: [MySQL] 58,665 pass(es).
[ View ]

That's because of a couple of use statements at the top of field.module that weren't actually needed, here's a reroll.

Status:Reviewed & tested by the community» Fixed

Committed and pushed to 8.x. Thanks!

+++ b/core/modules/field/lib/Drupal/field/Tests/FieldHelpTest.php
@@ -0,0 +1,69 @@
+    $this->assertNoLink('Telephone', 'Modules with field types that do not implement hook_help are not linked.');

This broke #2078813: Create hook_help for telephone module, and since all modules should have hook_help(), this is not really a great assumption. Can we remove the assertion, or should we write a new test field type module that doesn't have hook_help()? Please answer on the other issue.

Assigned:Unassigned» mr.baileys
Status:Fixed» Needs work

I'll rewrite the assertion so they use a test module instead of a core module.

Status:Needs work» Needs review
StatusFileSize
new1.67 KB
PASSED: [[SimpleTest]]: [MySQL] 58,954 pass(es).
[ View ]

...and here is a more sane way to test, using the existing field_test module to verify that modules implementing a widget and not having a hook_help() implementation list but not link to that module.

Might need a re-roll after #2078813: Create hook_help for telephone module lands.

Status:Needs review» Fixed

nm, after discussing with tim.plunkett and webchick in IRC, we decided this can be combined in #2078813: Create hook_help for telephone module

Status:Fixed» Closed (fixed)

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