Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave, longwave, larowlan: Deprecated function: array_slice(): Passing null to parameter #2 ($offset) of type int is deprecated in Drupal\Core\Config\Entity\Query\Query->execute()
parent
c506000f20
commit
6227621d38
|
@ -193,8 +193,8 @@ abstract class QueryBase implements QueryInterface {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function range($start = NULL, $length = NULL) {
|
public function range($start = NULL, $length = NULL) {
|
||||||
$this->range = [
|
$this->range = is_null($start) && is_null($length) ? [] : [
|
||||||
'start' => $start,
|
'start' => $start ?? 0,
|
||||||
'length' => $length,
|
'length' => $length,
|
||||||
];
|
];
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -499,6 +499,40 @@ class ConfigEntityQueryTest extends KernelTestBase {
|
||||||
->execute();
|
->execute();
|
||||||
$this->assertSame(['1', '2', '3'], array_values($this->queryResults));
|
$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));
|
||||||
|
|
||||||
|
// Explicitly pass NULL for the range and sort.
|
||||||
|
$this->queryResults = $this->entityStorage->getQuery()
|
||||||
|
->range(NULL, NULL)
|
||||||
|
->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));
|
||||||
|
|
||||||
|
// Request an empty range.
|
||||||
|
$this->queryResults = $this->entityStorage->getQuery()
|
||||||
|
->range(0, 0)
|
||||||
|
->execute();
|
||||||
|
$this->assertEmpty($this->queryResults);
|
||||||
|
|
||||||
// Apply a pager with limit 4.
|
// Apply a pager with limit 4.
|
||||||
$this->queryResults = $this->entityStorage->getQuery()
|
$this->queryResults = $this->entityStorage->getQuery()
|
||||||
->pager('4', 0)
|
->pager('4', 0)
|
||||||
|
|
Loading…
Reference in New Issue