Environment

  • Drupal core: 10
  • drupal/redirect_widget: 1.0.0-beta1
  • drupal/redirect: 1.11.0
  • content_moderation: no installed

Steps to reproduce

  1. Install/enable redirect module.
  2. Leave content_moderation disabled.
  3. Try to enable redirect_widget (UI or Drush).

Actual result
Container build fails with: The service "redirect_widget.manager" has a dependency on a non-existent service "content_moderation.moderation_information".


Technical notes

redirect_widget.services.yml injects @content_moderation.moderation_information as required.
redirect_widget.info.yml does not declare dependency on content_moderation.
Code in RedirectWidgetManager::isModerationStatePublished() already implies moderation is optional.

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:

Comments

jtor created an issue. See original summary.

mauro_’s picture

Thank you for reporting, will provide a fix next friday.

velmir_taky’s picture

Status: Active » Needs review
StatusFileSize
new1.79 KB

The redirect_widget.manager service has a hard dependency on @content_moderation.moderation_information, but content_moderation is not a required dependency of this module. When content_moderation is not installed, Drupal throws a Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException during container compilation, which prevents the module from being enabled at all.

Fix (2 files):

- redirect_widget.services.yml: Changed @content_moderation.moderation_information to @?content_moderation.moderation_information to mark it as an optional service.
- src/RedirectWidgetManager.php: Made the constructor parameter nullable (?ModerationInformationInterface) and added a null guard (|| !$this->moderationInformation) in isModerationStatePublished() so it gracefully returns TRUE when the service is not available.

Tested with and without content_moderation enabled — module installs and functions correctly in both scenarios.

  • mauro_ committed 3236c7e4 on main
    #3574880 fix issue with required moderation state service
    

  • mauro_ committed 3236c7e4 on 1.0.x
    #3574880 fix issue with required moderation state service
    
mauro_’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

mauro_’s picture

Status: Fixed » Closed (fixed)