Skip to content

Commit 020da9b

Browse files
authored
Merge pull request #8570 from kenjis/fix-for-backward-compat
[4.5] fix: errors when not updating Config\Feature
2 parents 76a7c6c + 013de17 commit 020da9b

File tree

7 files changed

+38
-19
lines changed

7 files changed

+38
-19
lines changed

system/BaseModel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,8 @@ public function findColumn(string $columnName)
650650
*/
651651
public function findAll(?int $limit = null, int $offset = 0)
652652
{
653-
if (config(Feature::class)->limitZeroAsAll) {
653+
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
654+
if ($limitZeroAsAll) {
654655
$limit ??= 0;
655656
}
656657

system/CodeIgniter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,8 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
466466
if ($routeFilters !== null) {
467467
$filters->enableFilters($routeFilters, 'before');
468468

469-
if (! config(Feature::class)->oldFilterOrder) {
469+
$oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false;
470+
if (! $oldFilterOrder) {
470471
$routeFilters = array_reverse($routeFilters);
471472
}
472473

system/Commands/Utilities/Routes/FilterFinder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public function find(string $uri): array
5757

5858
$this->filters->enableFilters($routeFilters, 'before');
5959

60-
if (! config(Feature::class)->oldFilterOrder) {
60+
$oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false;
61+
if (! $oldFilterOrder) {
6162
$routeFilters = array_reverse($routeFilters);
6263
}
6364

system/Database/BaseBuilder.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,8 @@ public function orderBy(string $orderBy, string $direction = '', ?bool $escape =
14931493
*/
14941494
public function limit(?int $value = null, ?int $offset = 0)
14951495
{
1496-
if (config(Feature::class)->limitZeroAsAll && $value === 0) {
1496+
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
1497+
if ($limitZeroAsAll && $value === 0) {
14971498
$value = null;
14981499
}
14991500

@@ -1614,7 +1615,8 @@ protected function compileFinalQuery(string $sql): string
16141615
*/
16151616
public function get(?int $limit = null, int $offset = 0, bool $reset = true)
16161617
{
1617-
if (config(Feature::class)->limitZeroAsAll && $limit === 0) {
1618+
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
1619+
if ($limitZeroAsAll && $limit === 0) {
16181620
$limit = null;
16191621
}
16201622

@@ -1751,7 +1753,8 @@ public function getWhere($where = null, ?int $limit = null, ?int $offset = 0, bo
17511753
$this->where($where);
17521754
}
17531755

1754-
if (config(Feature::class)->limitZeroAsAll && $limit === 0) {
1756+
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
1757+
if ($limitZeroAsAll && $limit === 0) {
17551758
$limit = null;
17561759
}
17571760

@@ -2473,7 +2476,8 @@ public function update($set = null, $where = null, ?int $limit = null): bool
24732476
$this->where($where);
24742477
}
24752478

2476-
if (config(Feature::class)->limitZeroAsAll && $limit === 0) {
2479+
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
2480+
if ($limitZeroAsAll && $limit === 0) {
24772481
$limit = null;
24782482
}
24792483

@@ -2518,7 +2522,8 @@ protected function _update(string $table, array $values): string
25182522
$valStr[] = $key . ' = ' . $val;
25192523
}
25202524

2521-
if (config(Feature::class)->limitZeroAsAll) {
2525+
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
2526+
if ($limitZeroAsAll) {
25222527
return 'UPDATE ' . $this->compileIgnore('update') . $table . ' SET ' . implode(', ', $valStr)
25232528
. $this->compileWhereHaving('QBWhere')
25242529
. $this->compileOrderBy()
@@ -2794,7 +2799,8 @@ public function delete($where = '', ?int $limit = null, bool $resetData = true)
27942799

27952800
$sql = $this->_delete($this->removeAlias($table));
27962801

2797-
if (config(Feature::class)->limitZeroAsAll && $limit === 0) {
2802+
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
2803+
if ($limitZeroAsAll && $limit === 0) {
27982804
$limit = null;
27992805
}
28002806

@@ -3064,7 +3070,8 @@ protected function compileSelect($selectOverride = false): string
30643070
. $this->compileWhereHaving('QBHaving')
30653071
. $this->compileOrderBy();
30663072

3067-
if (config(Feature::class)->limitZeroAsAll) {
3073+
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
3074+
if ($limitZeroAsAll) {
30683075
if ($this->QBLimit) {
30693076
$sql = $this->_limit($sql . "\n");
30703077
}

system/Database/SQLSRV/Builder.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ protected function _limit(string $sql, bool $offsetIgnore = false): string
313313
// DatabaseException:
314314
// [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The number of
315315
// rows provided for a FETCH clause must be greater then zero.
316-
if (! config(Feature::class)->limitZeroAsAll && $this->QBLimit === 0) {
316+
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
317+
if (! $limitZeroAsAll && $this->QBLimit === 0) {
317318
return "SELECT * \nFROM " . $this->_fromTables() . ' WHERE 1=0 ';
318319
}
319320

@@ -599,7 +600,8 @@ protected function compileSelect($selectOverride = false): string
599600
. $this->compileOrderBy(); // ORDER BY
600601

601602
// LIMIT
602-
if (config(Feature::class)->limitZeroAsAll) {
603+
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
604+
if ($limitZeroAsAll) {
603605
if ($this->QBLimit) {
604606
$sql = $this->_limit($sql . "\n");
605607
}
@@ -618,7 +620,8 @@ protected function compileSelect($selectOverride = false): string
618620
*/
619621
public function get(?int $limit = null, int $offset = 0, bool $reset = true)
620622
{
621-
if (config(Feature::class)->limitZeroAsAll && $limit === 0) {
623+
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
624+
if ($limitZeroAsAll && $limit === 0) {
622625
$limit = null;
623626
}
624627

system/Filters/Filters.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ public function initialize(?string $uri = null)
384384
return $this;
385385
}
386386

387-
if (config(Feature::class)->oldFilterOrder) {
387+
$oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false;
388+
if ($oldFilterOrder) {
388389
$this->processGlobals($uri);
389390
$this->processMethods();
390391
$this->processFilters($uri);
@@ -604,7 +605,8 @@ protected function processGlobals(?string $uri = null)
604605
}
605606

606607
if (isset($filters['before'])) {
607-
if (config(Feature::class)->oldFilterOrder) {
608+
$oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false;
609+
if ($oldFilterOrder) {
608610
$this->filters['before'] = array_merge($this->filters['before'], $filters['before']);
609611
} else {
610612
$this->filters['before'] = array_merge($filters['before'], $this->filters['before']);
@@ -649,7 +651,8 @@ protected function processMethods()
649651
}
650652

651653
if ($found) {
652-
if (config(Feature::class)->oldFilterOrder) {
654+
$oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false;
655+
if ($oldFilterOrder) {
653656
$this->filters['before'] = array_merge($this->filters['before'], $this->config->methods[$method]);
654657
} else {
655658
$this->filters['before'] = array_merge($this->config->methods[$method], $this->filters['before']);
@@ -706,16 +709,18 @@ protected function processFilters(?string $uri = null)
706709
}
707710
}
708711

712+
$oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false;
713+
709714
if (isset($filters['before'])) {
710-
if (config(Feature::class)->oldFilterOrder) {
715+
if ($oldFilterOrder) {
711716
$this->filters['before'] = array_merge($this->filters['before'], $filters['before']);
712717
} else {
713718
$this->filters['before'] = array_merge($filters['before'], $this->filters['before']);
714719
}
715720
}
716721

717722
if (isset($filters['after'])) {
718-
if (! config(Feature::class)->oldFilterOrder) {
723+
if (! $oldFilterOrder) {
719724
$filters['after'] = array_reverse($filters['after']);
720725
}
721726

system/Model.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ protected function doFindColumn(string $columnName)
252252
*/
253253
protected function doFindAll(?int $limit = null, int $offset = 0)
254254
{
255-
if (config(Feature::class)->limitZeroAsAll) {
255+
$limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true;
256+
if ($limitZeroAsAll) {
256257
$limit ??= 0;
257258
}
258259

0 commit comments

Comments
 (0)