Skip to content

Commit ee8e117

Browse files
authored
Merge pull request #8683 from kenjis/fix-Filters-4.5
[4.5] fix: TypeError in Filters
2 parents 879d002 + cceb1e8 commit ee8e117

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

system/Filters/Filters.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ private function setToolbarToLast(array $filters, bool $remove = false): array
376376
*
377377
* @param string|null $uri URI path relative to baseURL (all lowercase)
378378
*
379+
* @TODO We don't need to accept null as $uri.
380+
*
379381
* @return Filters
380382
*/
381383
public function initialize(?string $uri = null)
@@ -385,7 +387,7 @@ public function initialize(?string $uri = null)
385387
}
386388

387389
// Decode URL-encoded string
388-
$uri = urldecode($uri);
390+
$uri = urldecode($uri ?? '');
389391

390392
$oldFilterOrder = config(Feature::class)->oldFilterOrder ?? false;
391393
if ($oldFilterOrder) {

tests/system/Commands/Utilities/ConfigCheckTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public function testGetKintD()
9696
public 'allowedHostnames' -> array (0) []
9797
public 'indexPage' -> string (9) "index.php"
9898
public 'uriProtocol' -> string (11) "REQUEST_URI"
99+
public 'permittedURIChars' -> string (14) "a-z 0-9~%.:_\-"
99100
public 'defaultLocale' -> string (2) "en"
100101
public 'negotiateLocale' -> boolean false
101102
public 'supportedLocales' -> array (1) [
@@ -150,6 +151,8 @@ public function testGetVarDump()
150151
string(9) "index.php"
151152
public string $uriProtocol =>
152153
string(11) "REQUEST_URI"
154+
public string $permittedURIChars =>
155+
string(14) "a-z 0-9~%.:_\-"
153156
public string $defaultLocale =>
154157
string(2) "en"
155158
public bool $negotiateLocale =>
@@ -192,6 +195,8 @@ public function testGetVarDump()
192195
string(9) "index.php"
193196
["uriProtocol"]=>
194197
string(11) "REQUEST_URI"
198+
["permittedURIChars"]=>
199+
string(14) "a-z 0-9~%.:_\-"
195200
["defaultLocale"]=>
196201
string(2) "en"
197202
["negotiateLocale"]=>

tests/system/Filters/FiltersTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,8 +1097,8 @@ public function testMatchesURIWithUnicode(): void
10971097
'frak',
10981098
],
10991099
'after' => [
1100-
'baz',
11011100
'frak',
1101+
'baz',
11021102
],
11031103
];
11041104
$this->assertSame($expected, $filters->initialize($uri)->getFilters());

0 commit comments

Comments
 (0)