The Needs Review Queue Bot β tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide β to find step-by-step guides for working with issues.
- Status changed to Needs review
almost 2 years ago 6:37pm 31 January 2023 - π·π΄Romania amateescu
Rerolled and updated the patch with the new way of doing events, using class names instead of special constants.
- Status changed to Needs work
over 1 year ago 11:26pm 3 March 2023 - πΊπΈUnited States smustgrave
@trigger_error('The event dispatcher service should be passed to WorkspaceOperationFactory::__construct() since 9.4.0. This will be required in Drupal 10.0.0.', E_USER_DEPRECATED);
+ arguments: ['@entity_type.manager', '@database', '@workspaces.manager', '@workspaces.association', '@cache_tags.invalidator', '@event_dispatcher']
1, Will have to be updated. A 2nd change record may be needed to announce this service has a new parameter. And added to the message.
getSubscribedEvents
2. Should be typehinted3. Any new functions that return should be typehinted
- π¬π§United Kingdom longwave UK
+++ b/core/modules/workspaces/src/WorkspacePublisher.php @@ -62,14 +71,17 @@ class WorkspacePublisher implements WorkspacePublisherInterface { + $this->eventDispatcher = $event_dispatcher;
We need to add backward compatibility here; the $event_dispatcher argument could be the source workspace if callers have not been updated, in which case we need to issue a deprecation.
- Status changed to RTBC
over 1 year ago 10:10am 13 March 2023 - Status changed to Needs work
over 1 year ago 8:51am 31 March 2023 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Functionally this looks ready to go to me, however our standards for new code have changed since this was first created. I was tempted to fix these on commit but then it got to the point where a peer review felt appropriate.
Feel free to self RTBC after all these changes
-
+++ b/core/modules/content_moderation/src/EventSubscriber/WorkspaceSubscriber.php @@ -0,0 +1,109 @@ + /** + * The entity type manager service. + * + * @var \Drupal\Core\Entity\EntityTypeManagerInterface + */ + protected $entityTypeManager; + + /** + * The workspace association service. + * + * @var \Drupal\workspaces\WorkspaceAssociationInterface + */ + protected $workspaceAssociation; + + /** + * Constructs a new WorkspaceSubscriber instance. + * + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager + * The entity type manager service. + * @param \Drupal\workspaces\WorkspaceAssociationInterface $workspace_association + * The workspace association service. + */ + public function __construct(EntityTypeManagerInterface $entity_type_manager, WorkspaceAssociationInterface $workspace_association) { + $this->entityTypeManager = $entity_type_manager; + $this->workspaceAssociation = $workspace_association; + }
I realise this patch predates the requirement, but as this is new code, we need to use constructor property promotion here now
-
+++ b/core/modules/content_moderation/src/EventSubscriber/WorkspaceSubscriber.php @@ -0,0 +1,109 @@ + public function onWorkspacePrePublish(WorkspacePublishEvent $event) {
And need a return type hint here
-
+++ b/core/modules/content_moderation/src/EventSubscriber/WorkspaceSubscriber.php @@ -0,0 +1,109 @@ + // Find all workflows which are moderating entity types of the same type to
nit; >80 here
-
+++ b/core/modules/workspaces/src/Event/WorkspacePublishEvent.php @@ -0,0 +1,115 @@ + protected $publishingStopped = FALSE; ... + protected $publishingStoppedReason = '';
Can we get property type hints here too
-
+++ b/core/modules/workspaces/src/Event/WorkspacePublishEvent.php @@ -0,0 +1,115 @@ + * @param \Drupal\workspaces\WorkspaceInterface $workspace ... + public function __construct(WorkspaceInterface $workspace, array $published_revision_ids) {
and here too for constructor property promotion
-
+++ b/core/modules/workspaces/src/Event/WorkspacePublishEvent.php @@ -0,0 +1,115 @@ + public function stopPublishing() {
And a void return type here
-
+++ b/core/modules/workspaces/src/Event/WorkspacePublishEvent.php @@ -0,0 +1,115 @@ + public function setPublishingStoppedReason($reason) {
Should we make this fluent? if not can we add a void return type hint
-
+++ b/core/modules/workspaces/src/WorkspaceAssociation.php @@ -263,4 +267,23 @@ public function initializeWorkspace(WorkspaceInterface $workspace) { + public function onPostPublish(WorkspacePublishEvent $event) {
Can we add void here too
-
- Status changed to RTBC
over 1 year ago 12:44pm 31 March 2023 The last submitted patch, 38: 3242564-38.patch, failed testing. View results β
The last submitted patch, 38: 3242564-38.patch, failed testing. View results β
- Status changed to Needs review
over 1 year ago 11:50pm 3 April 2023 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
+++ b/core/modules/workspaces/src/WorkspacePublisher.php @@ -77,23 +93,28 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Con - throw new WorkspaceAccessException($message); + if ($this->sourceWorkspace->hasParent()) { + throw new WorkspacePublishException('Only top-level workspaces can be published.');
Should we have publish exception extend access exception? Someone may have code that is catching the access exception that will no longer catch from here? The fact we had to update our code here seems to indicate this is a potential BC break. If we don't want to have them extend that, we should at least add a second change notice with that detail.
+++ b/core/modules/workspaces/src/Event/WorkspacePublishEvent.php @@ -0,0 +1,112 @@ + public function setPublishingStoppedReason($reason): static {
Can we typehint $reason at all?
string|\Stringable
perhaps? - Status changed to RTBC
over 1 year ago 2:34pm 4 April 2023 - π·π΄Romania amateescu
1. I think it makes sense for the publish exception to extent access exception, because the reason for not being able to publish a workspace could very well be access-related.
2. Sure thing, done :)
- Status changed to Needs review
over 1 year ago 11:20pm 4 April 2023 -
larowlan β
committed 686537e1 on 10.1.x
Issue #3242564 by amateescu, larowlan, catch, Fabianx, longwave:...
-
larowlan β
committed 686537e1 on 10.1.x
- Status changed to Fixed
over 1 year ago 11:21pm 4 April 2023 - π¦πΊAustralia larowlan π¦πΊπ.au GMT+10
Whoops, didn't mean to update the status.
Committed to 10.1.x.
Not backporting because of the new API/deprecations.
Published the change notice
Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
7 months ago 3:21pm 29 April 2024 - π©πͺGermany stefan.korn Jossgrund
What is the deal about having the second argument optional here:
content_moderation.workspace_subscriber: class: Drupal\content_moderation\EventSubscriber\WorkspaceSubscriber arguments: ['@entity_type.manager', '@?workspaces.association']
but required there:
class WorkspaceSubscriber implements EventSubscriberInterface { ... public function __construct( protected readonly EntityTypeManagerInterface $entityTypeManager, protected readonly WorkspaceAssociationInterface $workspaceAssociation ) {}
as pointed out in π WorkspaceSubscriber service parameter $workspaceAssociation must be optional Needs work .
I came across this when devel quits the event info with an exception.
Actually
Drupal::service('event_dispatcher')->getListeners();
does not seem to work because of the difference between service definition and class implementation.
- π·π΄Romania amateescu
@stefan.korn, I replied in #3411308-10: WorkspaceSubscriber service parameter $workspaceAssociation must be optional β .