- Issue created by @ndf
- ๐ฎ๐ณIndia keshav patel
Keshav Patel โ made their first commit to this issueโs fork.
- Status changed to Needs review
11 months ago 9:11am 29 December 2023 - Merge request !5978Issue #3411308: Set workspaces.association as required in the service definition โ (Open) created by keshav patel
- ๐ณ๐ฑNetherlands ndf Amsterdam
@Keshev Patel, thanks for the MR. Can you please explain why you opted for the required parameter solution? This is helpful for other people to review your MR.
- Status changed to Needs work
11 months ago 5:25pm 29 December 2023 - ๐บ๐ธUnited States smustgrave
Yes an explanation is needed. Also a test case
- ๐ฎ๐ณIndia pooja saraah Chennai
In the original service definition, the second argument is specified as @?workspaces.association. The ? indicates that this argument is optional, meaning that the WorkspaceSubscriber class can accept either the workspaces.association service or no service at all.
In the modified service definition, the optional operator ? has been removed from the second argument. This means that the WorkspaceSubscriber class now explicitly expects the @workspaces.association service as a required argument.
Purpose of the Change:
The modification aligns the service definition with the actual constructor requirements of the WorkspaceSubscriber class. By removing the optional operator, the service definition accurately reflects that the WorkspaceSubscriber class expects the @workspaces.association service to be provided during instantiation. - ๐จ๐ฆCanada dstorozhuk Chicago ๐บ๐ธ, Toronto ๐จ๐ฆ, Kyiv ๐บ๐ฆ
After apply the patch from merge request !5978 I have that error.
The service "content_moderation.workspace_subscriber" has a dependency on a non-existent service "workspaces.association".
- ๐ท๐ดRomania amateescu
In the service definition, the
workspaces.association
service must be marked as optional because it might not exist (for example when the Workspaces module is not enabled).Note that this is not a bug because
\Drupal\content_moderation\EventSubscriber\WorkspaceSubscriber
is an event subscriber class, and it shouldn't be instantiated unless it needs to react to theWorkspacePrePublishEvent
event, which is only invoked when the Workspaces module is enabled. If some other module instantiates it.. well, it shouldn't :)If we want to make a change in core though, we need to mark the argument as optional in
\Drupal\content_moderation\EventSubscriber\WorkspaceSubscriber::__construct()
. Updated the issue summary to reflect that. - ๐ฉ๐ชGermany stefan.korn Jossgrund
stefan.korn โ made their first commit to this issueโs fork.
- ๐ฉ๐ชGermany stefan.korn Jossgrund
Thanks for the explanation.
As mentioned in ๐ Workspaces can't be published from the command line Fixed devel quits with WSOD on "Event info". And yes, this is happening if the content moderation module is installed and the workspaces module is not.
Basically
Drupal::service('event_dispatcher')->getListeners();
is failing then.
It seems to me that getListeners() without event argument is a valid call, therefore I am wondering if this should really end in error here (no exceptions for the method pointing in that direction either) even if the workspaces module is not installed.
And the difference between service definition (optional) and implementation (required) does also seem not really straightforward.
I have amended the MR to make the change in the implementation and not the service defintion.
- Status changed to RTBC
7 months ago 6:04am 30 April 2024 - ๐ท๐ดRomania amateescu
Ok, let's do this, the change is harmless and allows the class to be instantiated :)
- Status changed to Fixed
7 months ago 6:46am 30 April 2024 - ๐ฌ๐งUnited Kingdom catch
Committed/pushed to 11.x and cherry-picked to 10.3.x, thanks!