Unverified Commit e3829e1f authored by alexpott's avatar alexpott

Issue #2992817 by RoSk0, johndevman, phenaproxima, tim.plunkett, yanniboi,...

Issue #2992817 by RoSk0, johndevman, phenaproxima, tim.plunkett, yanniboi, alexpott: Layout builder cron errors when no cleanup required

(cherry picked from commit 964372f5)
parent 42c99acb
......@@ -87,8 +87,10 @@ public function removeByLayoutEntity(EntityInterface $entity) {
* The block content entity IDs.
*/
public function deleteUsage(array $block_content_ids) {
$query = $this->database->delete('inline_block_usage')->condition('block_content_id', $block_content_ids, 'IN');
$query->execute();
if (!empty($block_content_ids)) {
$query = $this->database->delete('inline_block_usage')->condition('block_content_id', $block_content_ids, 'IN');
$query->execute();
}
}
/**
......
<?php
namespace Drupal\Tests\layout_builder\Unit;
use Drupal\Core\Database\Connection;
use Drupal\layout_builder\InlineBlockUsage;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\layout_builder\InlineBlockUsage
*
* @group layout_builder
*/
class InlineBlockUsageTest extends UnitTestCase {
/**
* Tests calling deleteUsage() with empty array.
*
* @covers ::deleteUsage
*/
public function testEmptyDeleteUsageCall() {
$connection = $this->prophesize(Connection::class);
$connection->delete('inline_block_usage')->shouldNotBeCalled();
(new InlineBlockUsage($connection->reveal()))->deleteUsage([]);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment