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
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JulienD’s picture

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

JulienD’s picture

Status: Active » Needs review
FileSize
854 bytes

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

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me, thanks Julien :)

webchick’s picture

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.

mr.baileys’s picture

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
FileSize
5.43 KB

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.

mr.baileys’s picture

Issue tags: -Needs tests

Removing the "Needs tests" tag.

amateescu’s picture

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

mr.baileys’s picture

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.

mr.baileys’s picture

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.

mr.baileys’s picture

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

mr.baileys’s picture

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

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

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

alexpott’s picture

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

Patch no longer applies.

amateescu’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll
FileSize
5.04 KB

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

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

tim.plunkett’s picture

+++ 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.

mr.baileys’s picture

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

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

mr.baileys’s picture

Status: Needs work » Needs review
FileSize
1.67 KB

...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.

mr.baileys’s picture

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.