From 1a96b49cea8ab1d1ab858c88586a71c5c8a42548 Mon Sep 17 00:00:00 2001 From: Roderik Muit Date: Mon, 6 Nov 2023 19:19:52 +0100 Subject: [PATCH 1/2] fix: LDP-2307: remove any locks for nodes to be deleted by drush test:testCleanup. --- src/Drush/Commands/PlaywrightDrushCommands.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Drush/Commands/PlaywrightDrushCommands.php b/src/Drush/Commands/PlaywrightDrushCommands.php index 2e2d08e..8ebbbe2 100644 --- a/src/Drush/Commands/PlaywrightDrushCommands.php +++ b/src/Drush/Commands/PlaywrightDrushCommands.php @@ -256,6 +256,23 @@ public function cleanUpContent(string $keyword) { if (!empty($nids)) { $nodes = $node_storage->loadMultiple($nids); if (!empty($nodes)) { + if (\Drupal::hasService('content_lock')) { + // Release locks for all nodes. If this is not done: as of at least + // v8.x-2.3, content_lock_entity_predelete() does a hard redirect + // -outputting a HTML response to STDOUT- and exit(). + /** @var \Drupal\content_lock\ContentLock\ContentLock $lock_service */ + $lock_service = \Drupal::service('content_lock'); + foreach ($nodes as $node) { + if ($lock_service->isLockable($node)) { + $langcode = $node->language()->getId(); + $data = $lock_service->fetchLock($node->id(), NULL, $langcode, 'node'); + if ($data !== FALSE) { + $lock_service->release($node->id(), $langcode, '*'); + } + } + } + } + $node_storage->delete($nodes); } } From 2886e19814e80d436064dff86a46d22a2c119811 Mon Sep 17 00:00:00 2001 From: Roderik Muit Date: Mon, 6 Nov 2023 19:36:53 +0100 Subject: [PATCH 2/2] fix: LDP-2307: remove unnecessary wordiness in comment. --- src/Drush/Commands/PlaywrightDrushCommands.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Drush/Commands/PlaywrightDrushCommands.php b/src/Drush/Commands/PlaywrightDrushCommands.php index 8ebbbe2..c9c8a48 100644 --- a/src/Drush/Commands/PlaywrightDrushCommands.php +++ b/src/Drush/Commands/PlaywrightDrushCommands.php @@ -257,9 +257,8 @@ public function cleanUpContent(string $keyword) { $nodes = $node_storage->loadMultiple($nids); if (!empty($nodes)) { if (\Drupal::hasService('content_lock')) { - // Release locks for all nodes. If this is not done: as of at least - // v8.x-2.3, content_lock_entity_predelete() does a hard redirect - // -outputting a HTML response to STDOUT- and exit(). + // Never keep content with the specified keyword, regardless of lock + // status. /** @var \Drupal\content_lock\ContentLock\ContentLock $lock_service */ $lock_service = \Drupal::service('content_lock'); foreach ($nodes as $node) {