Updated: Comment #2
Problem/Motivation
Install minimal, uninstall node, InvalidArgumentException: No check has been registered for access_check.node.add in Drupal\Core\Access\AccessManager->loadCheck() (line 335 of core/lib/Drupal/Core/Access/AccessManager.php). Rebuild does not help. This because the Add Content link in the content menu does not get cleaned up.
Proposed resolution
Do not throw exceptions if the access check asked for is invalid -- just KILL. Note that there are many ways a situation like this could occur -- for example if you have dynamic services (we have a subsystem for that) and use such for an access check then this is just a small bug away. A bug like that, no matter how rare, should not bring the site completely down, to a place where not even rebuild helps. Especially not when it's quite easy to avoid this.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 2200127_13.patch | 2.67 KB | twistor |
| #10 | 2200127_8.patch | 1.01 KB | not_chx |
| #3 | 2200127_3.patch | 2.67 KB | not_chx |
Comments
Comment #1
chx commentedComment #2
chx commentedComment #3
not_chx commentedComment #4
chx commentedComment #5
btmash commentedI was starting to see that the source of the issue heading down what you have ended up patching. I also decided to take a look at the db tables as I suspect that rogue router entries were part of the cause of the issue. After node was uninstalled, router still contained 16 entries for paths containing node. I'm not sure why these entries were/are still around. Removing them also caused the issue to disappear.
Comment #6
btmash commentedI realized I was also able to wipe out the entries in the router table and that was rebuild so that would also fix the issue.
Since the router table had the stale entries, it doesn't seem like the router rebuild function (which happens upon cache flush at
\Drupal::service('router.builder')->rebuild();) is not wholly working as it should be.Comment #7
not_chx commentedI think this particular occurence of the issue is the node/add link in the tools menu. It has a 'system' module and so it's not removed and I presume we could patch that somehow. But that's just the occurence of this issue: I don't think that a broken link should immediately and unrecoverably bring down your site.
Comment #8
damiankloip commentedYes, what not_chx said. we talked about this in IRC. I debugged and this is certainly called from menu links, not router entries.
Comment #9
damiankloip commentedi.e. #2185967: Menu links no longer get removed if you uninstall the module they are provided by
Comment #10
not_chx commentedEven simpler version.
Comment #11
btmash commentedMenu links not being cleared correctly are a symptom of routers not being cleared out properly. But I will create another issue on this topic.
The patch looks good to me.
Comment #13
twistor commentedShould fix the test failures.
Comment #14
not_chx commentedComment #15
tim.plunkettThis sounds directly related to #2185967: Menu links no longer get removed if you uninstall the module they are provided by, which is in turn blocked by #2177041: Remove all implementations of hook_menu
Comment #16
damiankloip commentedAgreed. Mentioned that in #9.
Comment #17
dawehnerI wonder whether we can at least the failures? There needs to be a way to not fail silent. Hiding things is bad, at least this is my opinion.
Comment #18
not_chx commentedyou mean at least log the failures? I am sure there's a way but I do not know how to log errors in Drupal 8 (or do anything else. I just looked at where the exception is thrown and stopped it from propagating).
Comment #19
not_chx commentedI checked
core/core.services.ymlfor "log" but there's nothing (at least nothing relevant).Comment #20
catchI like trigger_error() for cases like this (not everyone else does, but it's the only way you get both logging and errors displayed on screen during development).
Comment #21
damiankloip commentedIt seems slightly mad to catch our own exceptions that we are throwing in the same class. I would personally just wait on the referenced issues above to fix this. Then if this does happen, it is an actual problem.
Comment #22
catchYep. Let's do this.
Comment #23
chx commentedApparently it was decided to eliminate the causes that can surface this behaviour instead of changing it. I neither disagree nor agree. I officially have no opinion. I only opened this because I thought it caused a migrate fail. Nothing to see here, please carry on.
Comment #24
damiankloip commentedThe patch at #2200185-10: Router table is not cleared when modules are uninstalled should also resolve this issue.
I think it might be worth keeping something from this issue. You never know what people will do to their sites.