Problem/Motivation

The hook_help text for the comment help text for the Comment module links to the node page. If the node module is uninstalled, then the site crashes. This issue can be re-created by on a minimal install with the help module installed.

There are some other modules that have similar problems: they link to pages or help pages for other modules that they do not actually depend on.

Proposed resolution

Escape the link to the node module in the help text of the comment module, and fix similar problems in other modules. (See the help text for the help module on how to do this.)

We actually made a test that goes through all the modules and finds these problems; the patch fixes all of them and makes the test pass. The test also verified that the module name (from the .info.yml file) was displayed on the help page; this failed for two modules so the patch in this issue fixes those two issues too (Tracker is actually Activity Tracker, and Action is actually Actions).

Remaining tasks

Make a patch that makes all the tests go green (done). Commit the patch.

User interface changes

Modules with only their dependencies enabled and Help enabled will not crash the site.

API changes

None.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug because if you disable the wrong modules, your system will crash. The patch also fixes some help text standards issues, like making sure the module name in the hook_help text matches the name in the .info.yml file.
Issue priority Normal... most people wouldn't disable this combination of modules.
Unfrozen changes Unfrozen because it only changes hook_help() implementations: text strings, documentation.
Prioritized changes Bug fixes are prioritized.
Disruption No disruption. Changes limited to some hook_help() implementations, which make the code and site more stable mostly, and/or make it comply with our help text standards.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ifrik’s picture

Working on this today.

ifrik’s picture

Status: Active » Needs work
FileSize
2.37 KB

This patch checks in the hook_help text of the comment module whether the node module exists.

If this works correctly then this needs to be applied to all other modules that call on modules that might not be enabled.

ifrik’s picture

Status: Needs work » Needs review
jhodgdon’s picture

Great!

Maybe we need to define a test for the Help module that turns on each individual module and verifies that the Help page for that module exists and can be reached with a 200 response code, and maybe that it contains the name of that module? That would future-proof this. The problem is I think the Comment module used to depend on Node (at least in 7 it definitely did), and now it doesn't, and no one updated the hook_help. We may have other cases in Core and it would be easier to find them in an automated way than to test them all manually over and over.

jhodgdon’s picture

I'm going to write this test now.

jhodgdon’s picture

OK, here's a patch that tests all the help pages for non-hidden modules.

I'm getting tons of "route not found" exceptions when I run this locally, on routes that should not have problems. So, checking to see if the test bot agrees... not sure what is going on. Either the exceptions are reporting the wrong problems (bad), or the routing is not working (bad), or I've done something wrong in how I'm installing modules in the test (maybe someone can tell me what that is). ???

ifrik’s picture

The link should look something like this (for a link to a Block module page for example)

array('!blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')

Status: Needs review » Needs work

The last submitted patch, 6: help-test-dependencies-2473105-test-only.patch, failed testing.

jhodgdon’s picture

Status: Needs work » Needs review
FileSize
5.51 KB

Here's a new test patch. I'm not sure whether we should include this test in Core or not, but it will at least help us identify the problems.

jhodgdon’s picture

Since this test might take a while to run, it might be good to combine it with the ModuleInstallUninstall test in system/Tests/Module. To do this, we might need to just run that test with Help module installed for most of that test, and then add a few lines to test the help.

And the install/uninstall of Help module could be tested separately from that main test.

Anyway... for now this test will fail and we cannot install it at least until we fix the actual problems in help pages that this test is finding.

Status: Needs review » Needs work

The last submitted patch, 9: help-test-dependencies-2473105-test-only-v2.patch, failed testing.

ifrik’s picture

Working on it further today....

ifrik’s picture

This patch escapes links to module page if the module is not installed.
It also escapes links to module help pages of modules that are not installed - otherwise the user gets a page-not-found error.

The test currently should fail for the books module because that one still has an open issue which takes this into account.

It might fail on the Update module because there is a message displayed after the module is disabled.
It also list an error that appears to be related to displaying the timezone of the user:
[19-Apr-2015 13:12:38 Europe/Berlin] Uncaught PHP Exception

I setting this for review to have it tested, but it probably needs more work to fix these.

The last submitted patch, 13: 2473105-escape-uninstalled-modules-with-test-13.patch, failed testing.

ifrik’s picture

Status: Needs review » Needs work
ifrik’s picture

Status: Needs work » Needs review
FileSize
79.14 KB

Fixing the links in Book and Configuration Manager module.

Status: Needs review » Needs work

The last submitted patch, 16: 2473105-escape-uninstalled-modules-with-test-16.patch, failed testing.

ifrik’s picture

Status: Needs work » Needs review
FileSize
84.13 KB

I've found to more links in help text in the aggregator and block module.

ifrik’s picture

Issue tags: +drupaldevdays

Status: Needs review » Needs work

The last submitted patch, 18: 2473105-escape-uninstalled-modules-with-test-18.patch, failed testing.

ifrik’s picture

jhodgdon: We are down to two fails, but I don't quite know what the message wants to tell me. Is it anything about errors in the module names?

jhodgdon’s picture

Those two fails are from the lines in the tests that verify that the name of the module that is in the info.yml file appears in the help with the word "module" after it.

So for instance: actions.info.yml apparently says the name of the module is "Actions", so it tests to see if the help text says "Actions module" in it, and apparently it doesn't. Same for tracker.info.yml, which has a module name of "Activity Tracker" so it looks to see if the help says "Activity Tracker module" in it, and apparently it doesn't.

ifrik’s picture

Here's a patch with and without test. On my laptop the test takes about 33 minutes to run.

  1. The patch fixes 3 different errors in the hook_help texts of the module files of all core modules:
  2. bug: links in the help text of a module to other modules that might not be enabled because they are not required for that module lead to a fatal error, so the routing needs to check first whether the module is enabled. If not the link is replaced. This had been done for most modules but not consequently for modules that are enabled by default.
  3. links to help texts of other modules. If these are not enabled the user gets a "Page not found error". It doesn't crash the site, but it's a bad user experience.
  4. Incorrect module names in the help text, for example "Action module" instead of "Actions module". This is simply a bad user experience.
jhodgdon’s picture

Status: Needs review » Needs work

Sorry for the review delay... I've been on vacation.

I don't see why we need a module exists('block') check in block_help() -- it's its own module??!?

+++ b/core/modules/block/block.module
@@ -30,7 +30,7 @@ function block_help($route_name, RouteMatchInterface $route_match) {
       $output .= '<dt>' . t('Toggling between different themes') . '</dt>';
       $output .= '<dd>' . t('Blocks are placed and configured specifically for each theme. The Block layout page opens with the default theme, but you can toggle to other installed themes.') . '</dd>';
       $output .= '<dt>' . t('Demonstrating block regions for a theme') . '</dt>';
-      $output .= '<dd>' . t('You can see where the regions are for the current theme by clicking the <em>Demonstrate block regions</em> link on the Block layout page. Regions are specific to each theme.', array('!blocks' => \Drupal::url('block.admin_display'))) . '</dd>';
+      $output .= '<dd>' . t('You can see where the regions are for the current theme by clicking the <em>Demonstrate block regions</em> link on the Block layout page. Regions are specific to each theme.', array('!blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>';

There are some other I think unnecessary tests in there:

ckeditor depends on editor, and editor depends on filter, so we should not need to check the existence of the filter module in ckeditor_help() or editor_help().

entity_reference, link, options, text, and file depend on field, so we should not need those tests either (we do need the tests for field_ui though in those help pages).

Node depends on text and entity_reference, both of which depend on the field module, so we should not need that test either.

Responsive image depends on image, which depends on file, which depends on field, so we should not need a test for field in that one.

The rest looks good though!

ifrik’s picture

Thanks,

I've re-rolled the change to the book page, because the text already got changed in a different patch.
Removed the tests where they are unnecessary as listed above.
I only found a test for field_ui in the responsive image module, not for field.

jhodgdon’s picture

Status: Needs review » Needs work

Better!

I think these tests are still not necessary:
block_content: !field-help' => (\Drupal::moduleHandler()->moduleExists('field'))
[block_content depends on text which depends on field]
text: '!formats' => (\Drupal::moduleHandler()->moduleExists('filter'))
[text depends on filter]

The rest looks right to me. Thanks!

jhodgdon’s picture

That reminds me, I need to rework that test so that it is integrated with the existing install/uninstall test, so that we can actually add it to Core. Maybe that should be a separate issue though.

The last submitted patch, 28: 2473105-escape-uninstalled-modules-28.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 28: 2473105-escape-uninstalled-modules-with-test-28.patch, failed testing.

ifrik’s picture

Sorry,
I had messed up my files.

ifrik’s picture

Thanks,

I've removed the unnecessary checks in the block_content and text modules.

Jhodgon, it would be great if you could make the test in a separate issue.

ifrik’s picture

Status: Needs work » Needs review
jhodgdon’s picture

Great, let's get this in!

Note to committer: DO NOT COMMIT THE "with test" patch. The test is very time consuming. It was used to diagnose the problem here, but what we want to do is integrate it with the module install/uninstall test so that we can keep Core help clean while not slowing down the test runs. I've filed #2488032: Integrate help test into module uninstall test for that task.

So the suggestion here is to commit the other patch. I'm hiding the "with tests" patch just to avoid the possibility of committing the time-consuming test by mistake.

Also updating issue summary.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 32: 2473105-escape-uninstalled-modules-31.patch, failed testing.

ifrik’s picture

Status: Needs work » Needs review
FileSize
62.68 KB

The views hook help text got fixed in a recent commit already, so I've taken the change to views.module out of the patch.

darol100’s picture

So, to test this out I would have to do the following:

  1. Install Drupal Minimal
  2. Install help module
  3. Unistall node module

And my website should crash ? By installing this patch it should not crash the site ?
I try to unistall the node module via the Drupal UI and did not let me. In addition, I try using

drush pm-unistall node

and did not work.

What I'm missing to test this patch ?

jhodgdon’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Reroll in #36 is verified -- I agree that another issue fixed the Views module and that is the only change removed in #36 as compared to the RTBC patch in #31. So, back to RTBC.

I guess we didn't have a full beta eval in the issue summary, so adding one.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 36: 2473105-escape-uninstalled-modules-36.patch, failed testing.

jhodgdon’s picture

Issue tags: +Needs reroll

Apparently needs another reroll...

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 36: 2473105-escape-uninstalled-modules-36.patch, failed testing.

ifrik’s picture

Status: Needs work » Needs review
FileSize
61.45 KB

The previous patch included changing the link to the online documentation from http to https. This has now been fixed by another patch.
I've taken the change of the config.module out of the patch. That's the only change.

Note: The help text for the config module is still getting worked on in #1831798: Update hook_help() for config manager module so any of the necessary changes to the content of the help text for the config modules are dealt with there.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

New patch checked over, agreed only change in config module, RTBC again.

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs reroll
Related issues: +#2468395: Core modules reference block module without first ensuring existance

I got permission from alexpott to commit this patch, so we can stop rerolling it. ;)

Committed to 8.0.x. Also credited contributors to #2468395: Core modules reference block module without first ensuring existance which is mostly a duplicate.

  • jhodgdon committed 6477492 on 8.0.x
    Issue #2473105 by ifrik, jhodgdon, lostkangaroo, opratr, LinL: Update...
David_Rothstein’s picture

It seems crazy fragile that a bad link like this can cause the whole webpage to break - I created #2498675: Linking to a non-existent route should not throw an exception as a followup for that underlying issue.

Status: Fixed » Closed (fixed)

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