From 0677a35325897fec68518dbf14620a1d02a13fa6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 22 Feb 2024 20:52:28 +0900 Subject: [PATCH 1/2] fix: Undefined property: Config\Feature::$oldFilterOrder When Config\Feature is not updated. --- system/CodeIgniter.php | 3 ++- system/Commands/Utilities/Routes/FilterFinder.php | 3 ++- system/Filters/Filters.php | 15 ++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 99a230e88436..e8d05fe3e6ad 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -466,7 +466,8 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache if ($routeFilters !== null) { $filters->enableFilters($routeFilters, 'before'); - if (! config(Feature::class)->oldFilterOrder) { + $oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false; + if (! $oldFilterOrder) { $routeFilters = array_reverse($routeFilters); } diff --git a/system/Commands/Utilities/Routes/FilterFinder.php b/system/Commands/Utilities/Routes/FilterFinder.php index f3c53b896568..57128e4a53d1 100644 --- a/system/Commands/Utilities/Routes/FilterFinder.php +++ b/system/Commands/Utilities/Routes/FilterFinder.php @@ -57,7 +57,8 @@ public function find(string $uri): array $this->filters->enableFilters($routeFilters, 'before'); - if (! config(Feature::class)->oldFilterOrder) { + $oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false; + if (! $oldFilterOrder) { $routeFilters = array_reverse($routeFilters); } diff --git a/system/Filters/Filters.php b/system/Filters/Filters.php index c4b2fc5a8688..b0c260fc6223 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -384,7 +384,8 @@ public function initialize(?string $uri = null) return $this; } - if (config(Feature::class)->oldFilterOrder) { + $oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false; + if ($oldFilterOrder) { $this->processGlobals($uri); $this->processMethods(); $this->processFilters($uri); @@ -604,7 +605,8 @@ protected function processGlobals(?string $uri = null) } if (isset($filters['before'])) { - if (config(Feature::class)->oldFilterOrder) { + $oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false; + if ($oldFilterOrder) { $this->filters['before'] = array_merge($this->filters['before'], $filters['before']); } else { $this->filters['before'] = array_merge($filters['before'], $this->filters['before']); @@ -649,7 +651,8 @@ protected function processMethods() } if ($found) { - if (config(Feature::class)->oldFilterOrder) { + $oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false; + if ($oldFilterOrder) { $this->filters['before'] = array_merge($this->filters['before'], $this->config->methods[$method]); } else { $this->filters['before'] = array_merge($this->config->methods[$method], $this->filters['before']); @@ -706,8 +709,10 @@ protected function processFilters(?string $uri = null) } } + $oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false; + if (isset($filters['before'])) { - if (config(Feature::class)->oldFilterOrder) { + if ($oldFilterOrder) { $this->filters['before'] = array_merge($this->filters['before'], $filters['before']); } else { $this->filters['before'] = array_merge($filters['before'], $this->filters['before']); @@ -715,7 +720,7 @@ protected function processFilters(?string $uri = null) } if (isset($filters['after'])) { - if (! config(Feature::class)->oldFilterOrder) { + if (! $oldFilterOrder) { $filters['after'] = array_reverse($filters['after']); } From 013de173ea79284e3450b6d2a546843203477b04 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 22 Feb 2024 21:02:28 +0900 Subject: [PATCH 2/2] fix: Undefined property: Config\Feature::$limitZeroAsAll When Config\Feature is not updated. --- system/BaseModel.php | 3 ++- system/Database/BaseBuilder.php | 21 ++++++++++++++------- system/Database/SQLSRV/Builder.php | 9 ++++++--- system/Model.php | 3 ++- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/system/BaseModel.php b/system/BaseModel.php index 8578fef233da..f12ea1f4c7c4 100644 --- a/system/BaseModel.php +++ b/system/BaseModel.php @@ -650,7 +650,8 @@ public function findColumn(string $columnName) */ public function findAll(?int $limit = null, int $offset = 0) { - if (config(Feature::class)->limitZeroAsAll) { + $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; + if ($limitZeroAsAll) { $limit ??= 0; } diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index caf136f4f184..ed20480cd730 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -1493,7 +1493,8 @@ public function orderBy(string $orderBy, string $direction = '', ?bool $escape = */ public function limit(?int $value = null, ?int $offset = 0) { - if (config(Feature::class)->limitZeroAsAll && $value === 0) { + $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; + if ($limitZeroAsAll && $value === 0) { $value = null; } @@ -1614,7 +1615,8 @@ protected function compileFinalQuery(string $sql): string */ public function get(?int $limit = null, int $offset = 0, bool $reset = true) { - if (config(Feature::class)->limitZeroAsAll && $limit === 0) { + $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; + if ($limitZeroAsAll && $limit === 0) { $limit = null; } @@ -1751,7 +1753,8 @@ public function getWhere($where = null, ?int $limit = null, ?int $offset = 0, bo $this->where($where); } - if (config(Feature::class)->limitZeroAsAll && $limit === 0) { + $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; + if ($limitZeroAsAll && $limit === 0) { $limit = null; } @@ -2473,7 +2476,8 @@ public function update($set = null, $where = null, ?int $limit = null): bool $this->where($where); } - if (config(Feature::class)->limitZeroAsAll && $limit === 0) { + $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; + if ($limitZeroAsAll && $limit === 0) { $limit = null; } @@ -2518,7 +2522,8 @@ protected function _update(string $table, array $values): string $valStr[] = $key . ' = ' . $val; } - if (config(Feature::class)->limitZeroAsAll) { + $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; + if ($limitZeroAsAll) { return 'UPDATE ' . $this->compileIgnore('update') . $table . ' SET ' . implode(', ', $valStr) . $this->compileWhereHaving('QBWhere') . $this->compileOrderBy() @@ -2794,7 +2799,8 @@ public function delete($where = '', ?int $limit = null, bool $resetData = true) $sql = $this->_delete($this->removeAlias($table)); - if (config(Feature::class)->limitZeroAsAll && $limit === 0) { + $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; + if ($limitZeroAsAll && $limit === 0) { $limit = null; } @@ -3064,7 +3070,8 @@ protected function compileSelect($selectOverride = false): string . $this->compileWhereHaving('QBHaving') . $this->compileOrderBy(); - if (config(Feature::class)->limitZeroAsAll) { + $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; + if ($limitZeroAsAll) { if ($this->QBLimit) { $sql = $this->_limit($sql . "\n"); } diff --git a/system/Database/SQLSRV/Builder.php b/system/Database/SQLSRV/Builder.php index cd77eb7adcf6..84531631d017 100755 --- a/system/Database/SQLSRV/Builder.php +++ b/system/Database/SQLSRV/Builder.php @@ -313,7 +313,8 @@ protected function _limit(string $sql, bool $offsetIgnore = false): string // DatabaseException: // [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]The number of // rows provided for a FETCH clause must be greater then zero. - if (! config(Feature::class)->limitZeroAsAll && $this->QBLimit === 0) { + $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; + if (! $limitZeroAsAll && $this->QBLimit === 0) { return "SELECT * \nFROM " . $this->_fromTables() . ' WHERE 1=0 '; } @@ -599,7 +600,8 @@ protected function compileSelect($selectOverride = false): string . $this->compileOrderBy(); // ORDER BY // LIMIT - if (config(Feature::class)->limitZeroAsAll) { + $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; + if ($limitZeroAsAll) { if ($this->QBLimit) { $sql = $this->_limit($sql . "\n"); } @@ -618,7 +620,8 @@ protected function compileSelect($selectOverride = false): string */ public function get(?int $limit = null, int $offset = 0, bool $reset = true) { - if (config(Feature::class)->limitZeroAsAll && $limit === 0) { + $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; + if ($limitZeroAsAll && $limit === 0) { $limit = null; } diff --git a/system/Model.php b/system/Model.php index bcb636b7f842..4c99f912fae0 100644 --- a/system/Model.php +++ b/system/Model.php @@ -252,7 +252,8 @@ protected function doFindColumn(string $columnName) */ protected function doFindAll(?int $limit = null, int $offset = 0) { - if (config(Feature::class)->limitZeroAsAll) { + $limitZeroAsAll = config(Feature::class)->limitZeroAsAll ?? true; + if ($limitZeroAsAll) { $limit ??= 0; }