From 0891ccc3c6504b61e96a6afc6cd99e2c28c818ab Mon Sep 17 00:00:00 2001 From: Andrey Pyzhikov <5071@mail.ru> Date: Wed, 7 Jun 2023 01:42:58 +0800 Subject: [PATCH] refactor: moving RedirectException. --- system/CodeIgniter.php | 2 +- .../Utilities/Routes/FilterFinder.php | 2 +- system/HTTP/Exceptions/RedirectException.php | 28 +++++++++++++++++++ .../Router/Exceptions/RedirectException.php | 2 ++ system/Router/Router.php | 2 +- system/Test/FeatureTestCase.php | 3 +- system/Test/FeatureTestTrait.php | 3 +- tests/system/Router/RouterTest.php | 2 +- user_guide_src/source/changelogs/v4.4.0.rst | 1 + 9 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 system/HTTP/Exceptions/RedirectException.php diff --git a/system/CodeIgniter.php b/system/CodeIgniter.php index 54e2f70f8872..2d919d3394cf 100644 --- a/system/CodeIgniter.php +++ b/system/CodeIgniter.php @@ -18,12 +18,12 @@ use CodeIgniter\Exceptions\PageNotFoundException; use CodeIgniter\HTTP\CLIRequest; use CodeIgniter\HTTP\DownloadResponse; +use CodeIgniter\HTTP\Exceptions\RedirectException; use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\Request; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\URI; -use CodeIgniter\Router\Exceptions\RedirectException; use CodeIgniter\Router\RouteCollectionInterface; use CodeIgniter\Router\Router; use Config\App; diff --git a/system/Commands/Utilities/Routes/FilterFinder.php b/system/Commands/Utilities/Routes/FilterFinder.php index 0f25eebf47f1..59e4ac49fbee 100644 --- a/system/Commands/Utilities/Routes/FilterFinder.php +++ b/system/Commands/Utilities/Routes/FilterFinder.php @@ -13,7 +13,7 @@ use CodeIgniter\Exceptions\PageNotFoundException; use CodeIgniter\Filters\Filters; -use CodeIgniter\Router\Exceptions\RedirectException; +use CodeIgniter\HTTP\Exceptions\RedirectException; use CodeIgniter\Router\Router; use Config\Services; diff --git a/system/HTTP/Exceptions/RedirectException.php b/system/HTTP/Exceptions/RedirectException.php new file mode 100644 index 000000000000..5cda9fb00cd0 --- /dev/null +++ b/system/HTTP/Exceptions/RedirectException.php @@ -0,0 +1,28 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace CodeIgniter\HTTP\Exceptions; + +use CodeIgniter\Exceptions\HTTPExceptionInterface; +use Exception; + +/** + * RedirectException + */ +class RedirectException extends Exception implements HTTPExceptionInterface +{ + /** + * HTTP status code for redirects + * + * @var int + */ + protected $code = 302; +} diff --git a/system/Router/Exceptions/RedirectException.php b/system/Router/Exceptions/RedirectException.php index a23d651855de..5e19e2e9ac5c 100644 --- a/system/Router/Exceptions/RedirectException.php +++ b/system/Router/Exceptions/RedirectException.php @@ -16,6 +16,8 @@ /** * RedirectException + * + * @deprecated Use \CodeIgniter\HTTP\Exceptions\RedirectException instead */ class RedirectException extends Exception implements HTTPExceptionInterface { diff --git a/system/Router/Router.php b/system/Router/Router.php index 8dd35c656e39..1ec3e6aa36d3 100644 --- a/system/Router/Router.php +++ b/system/Router/Router.php @@ -13,8 +13,8 @@ use Closure; use CodeIgniter\Exceptions\PageNotFoundException; +use CodeIgniter\HTTP\Exceptions\RedirectException; use CodeIgniter\HTTP\Request; -use CodeIgniter\Router\Exceptions\RedirectException; use CodeIgniter\Router\Exceptions\RouterException; /** diff --git a/system/Test/FeatureTestCase.php b/system/Test/FeatureTestCase.php index 2c2233df81b0..7119b914493b 100644 --- a/system/Test/FeatureTestCase.php +++ b/system/Test/FeatureTestCase.php @@ -12,12 +12,11 @@ namespace CodeIgniter\Test; use CodeIgniter\Events\Events; +use CodeIgniter\HTTP\Exceptions\RedirectException; use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\Request; use CodeIgniter\HTTP\URI; use CodeIgniter\HTTP\UserAgent; -use CodeIgniter\Router\Exceptions\RedirectException; -use CodeIgniter\Router\RouteCollection; use Config\Services; use Exception; use ReflectionException; diff --git a/system/Test/FeatureTestTrait.php b/system/Test/FeatureTestTrait.php index fd12efd4962b..30d6f23b2bf1 100644 --- a/system/Test/FeatureTestTrait.php +++ b/system/Test/FeatureTestTrait.php @@ -12,11 +12,10 @@ namespace CodeIgniter\Test; use CodeIgniter\Events\Events; +use CodeIgniter\HTTP\Exceptions\RedirectException; use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\Request; use CodeIgniter\HTTP\URI; -use CodeIgniter\Router\Exceptions\RedirectException; -use CodeIgniter\Router\RouteCollection; use Config\App; use Config\Services; use Exception; diff --git a/tests/system/Router/RouterTest.php b/tests/system/Router/RouterTest.php index 2898f154716e..bf23289ba191 100644 --- a/tests/system/Router/RouterTest.php +++ b/tests/system/Router/RouterTest.php @@ -13,8 +13,8 @@ use CodeIgniter\Config\Services; use CodeIgniter\Exceptions\PageNotFoundException; +use CodeIgniter\HTTP\Exceptions\RedirectException; use CodeIgniter\HTTP\IncomingRequest; -use CodeIgniter\Router\Exceptions\RedirectException; use CodeIgniter\Router\Exceptions\RouterException; use CodeIgniter\Test\CIUnitTestCase; use Config\Modules; diff --git a/user_guide_src/source/changelogs/v4.4.0.rst b/user_guide_src/source/changelogs/v4.4.0.rst index aab872fa6c1c..af154ec748be 100644 --- a/user_guide_src/source/changelogs/v4.4.0.rst +++ b/user_guide_src/source/changelogs/v4.4.0.rst @@ -143,6 +143,7 @@ Deprecations ``ExceptionHandler``. - **Autoloader:** ``Autoloader::sanitizeFilename()`` is deprecated. - **CodeIgniter:** ``CodeIgniter::$returnResponse`` property is deprecated. No longer used. +- **RedirectException:** ``\CodeIgniter\Router\Exceptions\RedirectException`` is deprecated. Use \CodeIgniter\HTTP\Exceptions\RedirectException instead. Bugs Fixed **********