this was originally posted in #2350797: Orphaned menu links when nodes are deleted if menu_link_ui is not enabled. I don't know if a regression of critical bug fix is critical but I'm opening this as such, please fix if incorrect.

I've found a new problem that comes with this (the fix of #2350797: Orphaned menu links when nodes are deleted if menu_link_ui is not enabled). Module uninstall is broken if configuration is being deleted during the uninstall. Here is one example how to reproduce:

  1. Install Drupal using the standard installation profile
  2. Download & Enable token contributed module
  3. Try to uninstall menu_link_content module

This gives error Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("entity_type_id") to generate a URL for route "entity.entity_view_mode.add_form".

I was able to reproduce this with drush and from UI.

(See also, comment #3, re: getting this error during automated site installation + config import.)

Comments

mikran created an issue. See original summary.

mikran’s picture

Issue summary: View changes
patrick r.’s picture

Ran to this issue as well after updating to 8.4.0-rc1 when doing an automated drush site-install with the current configuration of my project being imported after installation for testing purposes. After some investigation I also managed to trigger that exception by simply executing drush eval 'print_r(Drupal\Core\Entity\Entity\EntityViewMode::load("node.teaser")->uriRelationships());' on the command line. I think the problem might be that neither Drupal\Core\Entity\Entity\EntityViewMode nor Drupal\Core\Entity\EntityDisplayModeBase is extending Drupal\Core\Entity\Entity::urlRouteParameters() to provide the "entity_type_id" parameter for the "entity.entity_view_mode.add_form" route. Attaching a small patch which does just that.

amateescu’s picture

Status: Active » Needs review

Just closed a duplicate issue: #2908138: Core media module uninstall fails

There's a patch here so let's test the patch in #3.

mpp’s picture

Quite possible this one is a duplicate as well: https://www.drupal.org/node/2908021

The patch in #3 solved the issue for me. I assume the patch needs a test before it can get committed.

catch’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Yes let's add test coverage.

fellaroon’s picture

let us start a test coverage .

alison’s picture

EDIT: Crumbs, I copied/pasted carelessly and didn't even notice... Take 2...

Ran to this issue as well after updating to 8.4.0-rc1 when doing an automated drush site-install with the current configuration of my project being imported after installation for testing purposes.

(^^ comment #3) Me too!!!!! I will try the patch in a moment and report back. (I had been thinking that this had something to do with the Entity Schema changes in 8.4.0-rc1, or maybe it was in beta1, but this makes more sense; trying not to get my hopes up :D )

alison’s picture

Title: Orphaned menu links when nodes are deleted if menu_link_ui is not enabled issue fix broke module uninstalls » Orphaned menu routes breaking site installs and module uninstalls

(I hope this title change is okay; I wanted to reflect that this happens when installing sites with existing configurations, per #3; obviously feel free to change again!)

alison’s picture

Issue summary: View changes

Minor update to issue summary, just to mention the site installation + config import scenario from#3 (which is how I encountered the problem myself).

_randy’s picture

Confirmed patch in #3 solved the issue. Specifically mine was uninstalling the media module in D8.4-RC1.

amateescu’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new2.65 KB
new3.38 KB
new718 bytes

The patch in #3 is mostly correct, we just need to make sure that we only provide the extra route parameter when we need it.

Here's a test for this. The interdiff does not include the new test coverage :)

The last submitted patch, 12: 2907654-12-test-only.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 12: 2907654-12.patch, failed testing. View results

joelpittet’s picture

@amateescu, another guess that is probably too simple but could you compare the internal path instead of the full URL?

$view_mode->toUrl('edit-form')->getInternalPath() and remove the prefix /

joelpittet’s picture

I'll tackle my suggestion

joelpittet’s picture

Status: Needs work » Needs review
StatusFileSize
new2.98 KB
new3.71 KB
new3.55 KB

I replaced the paths with routes as Url objects. Seems to work well in local testing.

The last submitted patch, 17: 2907654-17-test-only.patch, failed testing. View results

iryston’s picture

Confirmed patch #3 as well as #17 (2907654-17.patch) solved the issue. Successfully uninstalling the comment module in Drupal 8.4-dev

catch’s picture

Status: Needs review » Reviewed & tested by the community

Nice straightforward test addition, moving back to RTBC.

  • catch committed 6487eda on 8.5.x
    Issue #2907654 by joelpittet, amateescu, Patrick R., mikran,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.5.x and cherry-picked to 8.4.x. Thanks!

  • catch committed 55ccc6c on 8.4.x
    Issue #2907654 by joelpittet, amateescu, Patrick R., mikran,...
alison’s picture

I think I'm still fine / I'm guessing (hoping) that this isn't a thing, but *just in case*..........

After updating to 8.4.0-rc2 (from rc1), and then also I had a couple config changes (a pathauto pattern, added a menu link to a view, site name tweak) -- the next time I ran drush cim, the import went fine, but I got an error that looked suspiciously similar to the stuff going on in this issue thread. Next time I ran a config import (albeit not the same config changes), no errors, so that's good. I should probably test with the same config import as the first time when I got the errors, but alas, I'm just pasting the error details here, for now anyway :) (If anyone thinks there's something to this, I will definitely recreate the situation and see if the error happens again, just lmk.)

✔ 18:08:39 alison: ~/path/to/vanilla2/web[master]$ drush cim
 Collection  Config                      Operation                
             pathauto.pattern.spotlight  update 
             system.site                 update 
             views.view.spotlight        update
Import the listed configuration changes? (y/n): y
Synchronized configuration: update pathauto.pattern.spotlight.                                              [ok]
Synchronized configuration: update system.site.                                                             [ok]
Synchronized configuration: update views.view.spotlight.                                                    [ok]
Finalizing configuration synchronization.                                                                   [ok]
The configuration was imported successfully.                                                                [success]
Argument 2 passed to Drupal\entity\Access\EntityRevisionRouteAccessChecker::__construct() must              [error]
implement interface Drupal\Core\Routing\RouteMatchInterface, instance of
Symfony\Component\HttpFoundation\RequestStack given, called in /path/to/vanilla2/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 266 and defined EntityRevisionRouteAccessChecker.php:46
E_RECOVERABLE_ERROR encountered; aborting. To ignore recoverable errors, run again with --no-halt-on-error  [error]
Drush command terminated abnormally due to an unrecoverable error.                                          [error]
wim leers’s picture

Title: Orphaned menu routes breaking site installs and module uninstalls » No URL can be generated for the 'add-form' route of EntityViewMode and EntityFormMode entities

The title here is far broader than what the fix entails — this was a fix only for EntityViewMode and EntityFormMode entities.

wim leers’s picture

As an unexpected side effect, this also unblocked #2843780 — see #2843780-32: EntityResource: Provide comprehensive test coverage for EntityFormMode entity. In that issue, we (or at least I) didn't realize there was a bug in the entity class for Entity(Form|View)Mode; now that that is fixed, that issue is also unblocked, hurray! And so is #2843781: EntityResource: Provide comprehensive test coverage for EntityViewMode entity!

Anonymous’s picture

Yep, renaming greatly helped this! 🙏

Status: Fixed » Closed (fixed)

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