Skip to content

Commit

Permalink
Merge pull request #7800 from kenjis/refactor-remove-callExit
Browse files Browse the repository at this point in the history
refactor: move callExit() to index.php
  • Loading branch information
kenjis authored Aug 14, 2023
2 parents 200cc6d + 13251a2 commit 4799e78
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,7 @@
*/

$app->run();

// Exits the application, setting the exit code for CLI-based applications
// that might be watching.
exit(EXIT_SUCCESS);
3 changes: 2 additions & 1 deletion system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ public function run(?RouteCollectionInterface $routes = null, bool $returnRespon
}

$this->sendResponse();
$this->callExit(EXIT_SUCCESS);
}

/**
Expand Down Expand Up @@ -1088,6 +1087,8 @@ protected function sendResponse()
* without actually stopping script execution.
*
* @param int $code
*
* @deprecated 4.4.0 No longer Used. Moved to index.php.
*/
protected function callExit($code)
{
Expand Down
5 changes: 5 additions & 0 deletions system/Test/Mock/MockCodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ class MockCodeIgniter extends CodeIgniter
{
protected ?string $context = 'web';

/**
* @param int $code
*
* @deprecated 4.4.0 No longer Used. Moved to index.php.
*/
protected function callExit($code)
{
// Do not call exit() in testing.
Expand Down
9 changes: 9 additions & 0 deletions user_guide_src/source/changelogs/v4.4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ Autoloader
Previously, CodeIgniter's autoloader allowed loading class names ending with the `.php` extension. This means instantiating objects like `new Foo.php()` was possible
and would instantiate as `new Foo()`. Since `Foo.php` is an invalid class name, this behavior of the autoloader is changed. Now, instantiating such classes would fail.

.. _v440-codeigniter-and-exit:

CodeIgniter and exit()
----------------------

The ``CodeIgniter::run()`` method no longer calls ``exit(EXIT_SUCCESS)``. The
exit call is moved to **public/index.php**.

.. _v440-interface-changes:

Interface Changes
Expand Down Expand Up @@ -263,6 +271,7 @@ Deprecations
- ``CodeIgniter::cache()`` method is deprecated. No longer used. Use ``ResponseCache`` instead.
- ``CodeIgniter::cachePage()`` method is deprecated. No longer used. Use ``ResponseCache`` instead.
- ``CodeIgniter::generateCacheName()`` method is deprecated. No longer used. Use ``ResponseCache`` instead.
- ``CodeIgniter::callExit()`` method is deprecated. No longer used.
- **RedirectException:** ``\CodeIgniter\Router\Exceptions\RedirectException`` is deprecated. Use ``\CodeIgniter\HTTP\Exceptions\RedirectException`` instead.
- **Session:** The property ``$sessionDriverName``, ``$sessionCookieName``,
``$sessionExpiration``, ``$sessionSavePath``, ``$sessionMatchIP``,
Expand Down
18 changes: 18 additions & 0 deletions user_guide_src/source/installation/upgrade_440.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,24 @@ match the new array structure.
Mandatory File Changes
**********************

index.php
=========

The following file received significant changes and
**you must merge the updated versions** with your application:

- ``public/index.php`` (see also :ref:`v440-codeigniter-and-exit`)

.. important:: If you don't update the above file, CodeIgniter will not work
properly after running ``composer update``.

The upgrade procedure, for example, is as follows:

.. code-block:: console
composer update
cp vendor/codeigniter4/framework/public/index.php public/index.php
Config Files
============

Expand Down

0 comments on commit 4799e78

Please sign in to comment.