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
- Enable the Workspaces module.
- Enable the Multiple Registration module.
- Visit a content type edit form, e.g.
/admin/structure/types/manage/page. - 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\AliasManagerInterfaceinstead ofDrupal\path_alias\AliasManager. - Update the
usestatement and the constructor parameter type (and@paramdocblock) 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.
Issue fork multiple_registration-3579036
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
Comment #4
ysamoylenko commentedThe patch looks good to me!
Comment #5
ysamoylenko commentedThe changes have been merged.