Skip to content

Commit f67bc68

Browse files
authored
refactor: Remove deprecated RedirectException (#9399)
* refacror: Remove CodeIgniter\Router\Exceptions\RedirectException * docs: Update changelog, userguide
1 parent 1f7e106 commit f67bc68

File tree

7 files changed

+6
-70
lines changed

7 files changed

+6
-70
lines changed

system/CodeIgniter.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
use CodeIgniter\HTTP\ResponsableInterface;
3030
use CodeIgniter\HTTP\ResponseInterface;
3131
use CodeIgniter\HTTP\URI;
32-
use CodeIgniter\Router\Exceptions\RedirectException as DeprecatedRedirectException;
3332
use CodeIgniter\Router\RouteCollectionInterface;
3433
use CodeIgniter\Router\Router;
3534
use Config\App;
@@ -353,11 +352,8 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
353352
} else {
354353
try {
355354
$this->response = $this->handleRequest($routes, config(Cache::class), $returnResponse);
356-
} catch (DeprecatedRedirectException|ResponsableInterface $e) {
355+
} catch (ResponsableInterface $e) {
357356
$this->outputBufferingEnd();
358-
if ($e instanceof DeprecatedRedirectException) {
359-
$e = new RedirectException($e->getMessage(), $e->getCode(), $e);
360-
}
361357

362358
$this->response = $e->getResponse();
363359
} catch (PageNotFoundException $e) {

system/Router/Exceptions/RedirectException.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/system/CodeIgniterTest.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use CodeIgniter\Exceptions\PageNotFoundException;
2020
use CodeIgniter\HTTP\Method;
2121
use CodeIgniter\HTTP\Response;
22-
use CodeIgniter\Router\Exceptions\RedirectException;
2322
use CodeIgniter\Router\RouteCollection;
2423
use CodeIgniter\Test\CIUnitTestCase;
2524
use CodeIgniter\Test\Filters\CITestStreamFilter;
@@ -600,29 +599,6 @@ public function testRunRedirectionWithPOSTAndHTTPCode301(): void
600599
$this->assertSame(301, $response->getStatusCode());
601600
}
602601

603-
/**
604-
* test for deprecated \CodeIgniter\Router\Exceptions\RedirectException for backward compatibility
605-
*/
606-
public function testRedirectExceptionDeprecated(): void
607-
{
608-
$_SERVER['argv'] = ['index.php', '/'];
609-
$_SERVER['argc'] = 2;
610-
611-
// Inject mock router.
612-
$routes = service('routes');
613-
$routes->get('/', static function (): never {
614-
throw new RedirectException('redirect-exception', 503);
615-
});
616-
617-
$router = service('router', $routes, service('incomingrequest'));
618-
Services::injectMock('router', $router);
619-
620-
$response = $this->codeigniter->run($routes, true);
621-
622-
$this->assertSame(503, $response->getStatusCode());
623-
$this->assertSame('http://example.com/redirect-exception', $response->getHeaderLine('Location'));
624-
}
625-
626602
public function testStoresPreviousURL(): void
627603
{
628604
$_SERVER['argv'] = ['index.php', '/'];

user_guide_src/source/changelogs/v4.6.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ Removed Deprecated Items
198198
- **Logger:** The deprecated ``CodeIgniter\Log\Logger::cleanFilenames()`` and
199199
``CodeIgniter\Test\TestLogger::cleanup()`` have been removed. Use the
200200
``clean_path()`` function instead.
201+
**Router:** The deprecated ``CodeIgniter\Router\Exceptions\RedirectException`` has been removed. Use ``CodeIgniter\HTTP\Exceptions\RedirectException`` instead.
201202

202203
************
203204
Enhancements

user_guide_src/source/general/errors.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ RedirectException
209209

210210
.. note:: Since v4.4.0, the namespace of ``RedirectException`` has been changed.
211211
Previously it was ``CodeIgniter\Router\Exceptions\RedirectException``. The
212-
previous class is deprecated.
212+
previous class has been removed in v4.6.0.
213213

214214
This exception is a special case allowing for overriding of all other response routing and
215215
forcing a redirect to a specific URI:

utils/phpstan-baseline/codeigniter.superglobalAccessAssign.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ parameters:
164164

165165
-
166166
message: '#^Assigning 2 directly on offset ''argc'' of \$_SERVER is discouraged\.$#'
167-
count: 27
167+
count: 26
168168
path: ../../tests/system/CodeIgniterTest.php
169169

170170
-
171171
message: '#^Assigning array\{''index\.php'', ''/''\} directly on offset ''argv'' of \$_SERVER is discouraged\.$#'
172-
count: 12
172+
count: 11
173173
path: ../../tests/system/CodeIgniterTest.php
174174

175175
-

utils/phpstan-baseline/property.phpDocType.neon

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 48 errors
1+
# total 47 errors
22

33
parameters:
44
ignoreErrors:
@@ -172,11 +172,6 @@ parameters:
172172
count: 1
173173
path: ../../system/Images/Handlers/ImageMagickHandler.php
174174

175-
-
176-
message: '#^PHPDoc type int of property CodeIgniter\\Router\\Exceptions\\RedirectException\:\:\$code is not the same as PHPDoc type mixed of overridden property Exception\:\:\$code\.$#'
177-
count: 1
178-
path: ../../system/Router/Exceptions/RedirectException.php
179-
180175
-
181176
message: '#^PHPDoc type string of property CodeIgniter\\Session\\Handlers\\FileHandler\:\:\$savePath is not the same as PHPDoc type array\|string of overridden property CodeIgniter\\Session\\Handlers\\BaseHandler\:\:\$savePath\.$#'
182177
count: 1

0 commit comments

Comments
 (0)