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.

CommentFileSizeAuthor
#13 2200127_13.patch2.67 KBtwistor
#10 2200127_8.patch1.01 KBnot_chx
#3 2200127_3.patch2.67 KBnot_chx

Comments

chx’s picture

Issue summary: View changes
chx’s picture

Issue summary: View changes
not_chx’s picture

StatusFileSize
new2.67 KB
chx’s picture

Component: other » routing system
Issue summary: View changes
Status: Active » Needs review
btmash’s picture

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

btmash’s picture

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

not_chx’s picture

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

damiankloip’s picture

Yes, what not_chx said. we talked about this in IRC. I debugged and this is certainly called from menu links, not router entries.

not_chx’s picture

StatusFileSize
new1.01 KB

Even simpler version.

btmash’s picture

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

Status: Needs review » Needs work

The last submitted patch, 10: 2200127_8.patch, failed testing.

twistor’s picture

Status: Needs work » Needs review
StatusFileSize
new2.67 KB

Should fix the test failures.

not_chx’s picture

Title: No check has been registered for access_check.node.add » Orphaned menu links bring down the site
Issue summary: View changes
tim.plunkett’s picture

damiankloip’s picture

Agreed. Mentioned that in #9.

dawehner’s picture

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

not_chx’s picture

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

not_chx’s picture

I checked core/core.services.yml for "log" but there's nothing (at least nothing relevant).

catch’s picture

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

damiankloip’s picture

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

catch’s picture

Status: Needs review » Postponed

Yep. Let's do this.

chx’s picture

Status: Postponed » Closed (works as designed)

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

damiankloip’s picture

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