Commit 301c19da authored by catch's avatar catch
Browse files

Issue #3438769 by vinmayiswamy, amateescu, catch, antonnavi, michelle: Sub workspace does not clear

(cherry picked from commit 2cfb0738)
parent c05d7345
Loading
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -439,7 +439,12 @@ public static function getSubscribedEvents(): array {
   *   The workspace publish event.
   */
  public function onPostPublish(WorkspacePublishEvent $event): void {
    $this->deleteAssociations($event->getWorkspace()->id());
    // Cleanup associations for the published workspace as well as its
    // descendants.
    $affected_workspaces = $this->workspaceRepository->getDescendantsAndSelf($event->getWorkspace()->id());
    foreach ($affected_workspaces as $workspace_id) {
      $this->deleteAssociations($workspace_id);
    }
  }

}
+8 −0
Original line number Diff line number Diff line
@@ -156,6 +156,14 @@ public function testWorkspaceAssociation(): void {
    $expected_initial_revisions['dev'] = [8];

    $this->assertWorkspaceAssociations('node', $expected_latest_revisions, $expected_all_revisions, $expected_initial_revisions);

    // Publish 'stage' and check the workspace associations.
    /** @var \Drupal\workspaces\WorkspacePublisherInterface $workspace_publisher */
    $workspace_publisher = \Drupal::service('workspaces.operation_factory')->getPublisher($this->workspaces['stage']);
    $workspace_publisher->publish();

    $expected_revisions['stage'] = $expected_revisions['dev'] = [];
    $this->assertWorkspaceAssociations('node', $expected_revisions, $expected_revisions, $expected_revisions);
  }

  /**