Problem/Motivation

The content_moderation module does not have a dependency on node.module, yet the controller for the content_moderation.admin_moderated_content route depends on the node entity type.

Steps to reproduce

  1. Install Drupal with minimal profile
  2. Install content_moderation module
  3. Uninstall node module
  4. Visit /admin/content/moderated

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "node" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 150 of /app/web/core/lib/Drupal/Core/Entity/EntityTypeManager.php).

Proposed resolution

Add a module dependency on the content_moderation.admin_moderated_content route and provide the local task via the DynamicLocalTasks deriver if the route exists.

Remaining tasks

Review and commit

User interface changes

Moderated content local task no longer appears if node module is not installed.

API changes

Added $router parameter to \Drupal\content_moderation\Plugin\Derivative\DynamicLocalTasks::__construct()

Data model changes

Release notes snippet

Issue fork drupal-3211072

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mstrelan created an issue. See original summary.

mstrelan’s picture

I tried adding _module_dependencies: 'node' to the content_moderation.admin_moderated_content route but this results in the content_moderation.moderated_content local task throwing an error that the route does not exist.

mstrelan’s picture

Issue summary: View changes
mstrelan’s picture

Issue summary: View changes
mstrelan’s picture

Status: Active » Needs review

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

larowlan’s picture

Just one minor nitpick, other than that this looks really solid

Sam152’s picture

Status: Needs review » Reviewed & tested by the community

All looks very reasonable to me. Nice.

  • larowlan committed bb180f9 on 9.3.x
    Issue #3211072 by mstrelan: ModeratedContentController has an unlisted...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +Bug Smash Initiative

Applied this locally because the MR is against 9.2.x

Committed bb180f9 and pushed to 9.3.x. Thanks!

Because of the constructor change, which is allowed in a Plugin under our BC policy, this is too disruptive for backporting to 9.2.x

Added a change notice for the above

Status: Fixed » Closed (fixed)

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

acbramley’s picture

Just an FYI - this will cause sites that previously removed this local task via hook_local_tasks_alter to suddenly start displaying it.

For whatever reason, it seems like derivatives are added AFTER the alter hook runs, which I find very odd.