Skip to content

Commit 1b5108e

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.6
2 parents b469f0c + 75a0d9a commit 1b5108e

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

system/Router/RouteCollection.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,12 @@ protected function create(string $verb, string $from, $to, ?array $options = nul
14561456
$to = $this->processArrayCallableSyntax($from, $to);
14571457
}
14581458

1459+
// Merge group filters.
1460+
if (isset($options['filter'])) {
1461+
$currentFilter = (array) ($this->currentOptions['filter'] ?? []);
1462+
$options['filter'] = array_merge($currentFilter, (array) $options['filter']);
1463+
}
1464+
14591465
$options = array_merge($this->currentOptions ?? [], $options ?? []);
14601466

14611467
// Route priority detect

tests/system/Router/RouteCollectionTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,22 @@ static function ($routes): void {
441441
$this->assertSame($expected, $routes->getRoutesOptions());
442442
}
443443

444+
public function testGroupFilterAndRouteFilter(): void
445+
{
446+
$routes = $this->getCollector();
447+
448+
$routes->group('admin', ['filter' => ['csrf']], static function ($routes): void {
449+
$routes->get('profile', 'Admin\Profile::index', ['filter' => ['honeypot']]);
450+
});
451+
452+
$expected = [
453+
'admin/profile' => [
454+
'filter' => ['csrf', 'honeypot'],
455+
],
456+
];
457+
$this->assertSame($expected, $routes->getRoutesOptions());
458+
}
459+
444460
public function testGroupingWorksWithEmptyStringPrefix(): void
445461
{
446462
$routes = $this->getCollector();

user_guide_src/source/changelogs/v4.5.4.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Deprecations
3030
Bugs Fixed
3131
**********
3232

33+
- **Routing:** Fixed a bug that filters passed to ``$routes->group()`` were not
34+
merged into filters passed to the inner routes.
3335
- **CURLRequest:** Fixed a bug preventing the use of strings for ``version`` in the config array
3436
when making requests.
3537

user_guide_src/source/general/configuration.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@ Registrars provide a means of altering a configuration at runtime across namespa
314314
Registrars work if :ref:`auto-discovery` is enabled in :doc:`Modules </general/modules>`.
315315
It alters configuration properties when the Config object is instantiated.
316316

317+
.. note:: This feature is implemented in the ``CodeIgniter\Config\BaseConfig``
318+
class. So it will not work with a few files in the **app/Config** folder
319+
that do not extends the class.
320+
317321
There are two ways to implement a Registrar: **implicit** and **explicit**.
318322

319323
.. note:: Values from **.env** always take priority over Registrars.

user_guide_src/source/incoming/routing.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,9 @@ run the filter before or after the controller. This is especially handy during a
564564

565565
The value for the filter must match one of the aliases defined within **app/Config/Filters.php**.
566566

567+
.. note:: Prior to v4.5.4, due to a bug, filters passed to the ``group()`` were
568+
not merged into the filters passed to the inner routes.
569+
567570
Setting Other Options
568571
=====================
569572

0 commit comments

Comments
 (0)