Verified Commit 2deae09a authored by Dave Long's avatar Dave Long
Browse files

Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave: Deprecated...

Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave: Deprecated function: array_slice(): Passing null to parameter #2 ($offset) of type int is deprecated in Drupal\Core\Config\Entity\Query\Query->execute()

(cherry picked from commit 8226fe88)
parent e891703e
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -193,10 +193,10 @@ public function notExists($property, $langcode = NULL) {
   * {@inheritdoc}
   */
  public function range($start = NULL, $length = NULL) {
    $this->range = [
      'start' => $start,
    $this->range = $start || $length ? [
      'start' => $start ?? 0,
      'length' => $length,
    ];
    ] : [];
    return $this;
  }

+21 −0
Original line number Diff line number Diff line
@@ -499,6 +499,27 @@ public function testSortRange() {
      ->execute();
    $this->assertSame(['1', '2', '3'], array_values($this->queryResults));

    // Omit optional parameters for the range and sort.
    $this->queryResults = $this->entityStorage->getQuery()
      ->range()
      ->sort('id')
      ->execute();
    $this->assertSame(['1', '2', '3', '4', '5', '6', '7'], array_values($this->queryResults));

    // Omit the optional start parameter for the range.
    $this->queryResults = $this->entityStorage->getQuery()
      ->range(NULL, 1)
      ->sort('id')
      ->execute();
    $this->assertSame(['1'], array_values($this->queryResults));

    // Omit the optional length parameter for the range.
    $this->queryResults = $this->entityStorage->getQuery()
      ->range(4)
      ->sort('id')
      ->execute();
    $this->assertSame(['5', '6', '7'], array_values($this->queryResults));

    // Apply a pager with limit 4.
    $this->queryResults = $this->entityStorage->getQuery()
      ->pager('4', 0)