Commit 0c01d924 authored by catch's avatar catch
Browse files

Issue #3184170 by BR0kEN, daffie, jonathanshaw, neclimdul, catch: The...

Issue #3184170 by BR0kEN, daffie, jonathanshaw, neclimdul, catch: The `releaseItem()` and `delayItem()` of `Drupal\Core\Queue\DatabaseQueue` violates interfaces return type specifications

(cherry picked from commit 986fdecf)
parent f0bc5dee
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -162,7 +162,7 @@ public function releaseItem($item) {
          'expire' => 0,
        ])
        ->condition('item_id', $item->item_id);
      return $update->execute();
      return (bool) $update->execute();
    }
    catch (\Exception $e) {
      $this->catchException($e);
@@ -189,7 +189,7 @@ public function delayItem($item, int $delay) {
          'expire' => $expire,
        ])
        ->condition('item_id', $item->item_id);
      return $update->execute();
      return (bool) $update->execute();
    }
    catch (\Exception $e) {
      $this->catchException($e);
+19 −0
Original line number Diff line number Diff line
@@ -182,4 +182,23 @@ public function testExceptions() {
    $this->assertEquals(0, $queue->numberOfItems());
  }

  /**
   * Tests that database queue implementation complies with interfaces specs.
   */
  public function testDatabaseQueueReturnTypes(): void {
    /** @var \Drupal\Core\Queue\DatabaseQueue $queue */
    $queue = $this->container
      ->get('queue')
      ->get('cron_queue_test_database_delay_exception');
    static::assertInstanceOf(DatabaseQueue::class, $queue);

    $queue->createItem(12);
    $item = $queue->claimItem();
    static::assertTrue($queue->delayItem($item, 1));
    static::assertTrue($queue->releaseItem($item));
    $queue->deleteItem($item);
    static::assertFalse($queue->delayItem($item, 1));
    static::assertFalse($queue->releaseItem($item));
  }

}