Problem/Motivation

When the Workspaces module is enabled, Drupal decorates the path_alias.manager service with Drupal\workspaces\WorkspacesAliasManager. MultipleRegistrationController type-hints the constructor argument as the concrete class Drupal\path_alias\AliasManager, so the container injects WorkspacesAliasManager and PHP throws a TypeError.

Error: Argument #3 ($aliasManager) must be of type Drupal\path_alias\AliasManager, Drupal\workspaces\WorkspacesAliasManager given.

This occurs on any page that runs an access check involving the Multiple Registration controller (e.g. node type edit form at /admin/structure/types/manage/%node_type when menu_ui checks the multiple_registration.role_registration_page route).

Steps to reproduce

  1. Enable the Workspaces module.
  2. Enable the Multiple Registration module.
  3. Visit a content type edit form, e.g. /admin/structure/types/manage/page.
  4. Observe an unexpected error page with the TypeError above.

Proposed resolution

Type-hint the alias manager by interface instead of the concrete class. In MultipleRegistrationController:

  • Inject Drupal\path_alias\AliasManagerInterface instead of Drupal\path_alias\AliasManager.
  • Update the use statement and the constructor parameter type (and @param docblock) accordingly.

The controller only calls getAliasByPath(), which is defined on AliasManagerInterface. Both AliasManager and WorkspacesAliasManager implement that interface, so the change is backward compatible and fixes the error when Workspaces is enabled.

Remaining tasks

  • Review and commit the patch.

User interface changes

None. Fixes the error so affected admin pages load normally when Workspaces is enabled.

API changes

None. The public API of the controller is unchanged; only the type of an injected dependency is widened from a concrete class to its interface.

Data model changes

None.

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

thinkingcap created an issue. See original summary.

ysamoylenko made their first commit to this issue’s fork.

ysamoylenko’s picture

Version: 3.3.2 » 3.x-dev
Status: Active » Reviewed & tested by the community

The patch looks good to me!

ysamoylenko’s picture

Status: Reviewed & tested by the community » Fixed

The changes have been merged.

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.

Status: Fixed » Closed (fixed)

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