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
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. |
Comment | File | Size | Author |
---|---|---|---|
#43 | 2473105-escape-uninstalled-modules-42.patch | 61.45 KB | ifrik |
#36 | 2473105-escape-uninstalled-modules-36.patch | 62.68 KB | ifrik |
#32 | 2473105-escape-uninstalled-modules-31.patch | 64.56 KB | ifrik |
Comments
Comment #1
ifrikWorking on this today.
Comment #2
ifrikThis 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.
Comment #3
ifrikComment #4
jhodgdonGreat!
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.
Comment #5
jhodgdonI'm going to write this test now.
Comment #6
jhodgdonOK, 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). ???
Comment #7
ifrikThe 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') : '#')
Comment #9
jhodgdonHere'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.
Comment #10
jhodgdonSince 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.
Comment #12
ifrikWorking on it further today....
Comment #13
ifrikThis 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.
Comment #15
ifrikComment #16
ifrikFixing the links in Book and Configuration Manager module.
Comment #18
ifrikI've found to more links in help text in the aggregator and block module.
Comment #19
ifrikComment #21
ifrikjhodgdon: 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?
Comment #22
jhodgdonThose 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.
Comment #23
ifrikHere's a patch with and without test. On my laptop the test takes about 33 minutes to run.
Comment #24
jhodgdonSorry 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??!?
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!
Comment #25
ifrikThanks,
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.
Comment #26
jhodgdonBetter!
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!
Comment #27
jhodgdonThat 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.
Comment #31
ifrikSorry,
I had messed up my files.
Comment #32
ifrikThanks,
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.
Comment #33
ifrikComment #34
jhodgdonGreat, 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.
Comment #36
ifrikThe views hook help text got fixed in a recent commit already, so I've taken the change to views.module out of the patch.
Comment #37
darol100 CreditAttribution: darol100 as a volunteer and commentedSo, to test this out I would have to do the following:
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
and did not work.
What I'm missing to test this patch ?
Comment #38
jhodgdonReroll 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.
Comment #40
jhodgdonApparently needs another reroll...
Comment #43
ifrikThe 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.
Comment #44
jhodgdonNew patch checked over, agreed only change in config module, RTBC again.
Comment #45
jhodgdonI 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.
Comment #47
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedIt 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.