Skip to content

[4.4] refactor: a single point of sending the Response. - #7519

Merged
kenjis merged 2 commits into
codeigniter4:4.4from
iRedds:sending-response
Jun 6, 2023
Merged

kenjis merged 2 commits into
codeigniter4:4.4from
iRedds:sending-response

Conversation

@iRedds

@iRedds iRedds commented May 24, 2023

Copy link
Copy Markdown
Collaborator

Description
This PR refactors the CodeIgniter class code so that all successful responses, except those caused by exceptions, are sent from one place.

  • The CodeIgniter::handleRequest() method now always returns a Response.
  • Moved HTTP cli check and page cache check to CodeIgniter::handleRequest() method. Because these methods generate a Response and are actually part of the request processing.
  • Event call Events::trigger('pre_system') moved to method CodeIgniter::handleRequest() and is now on the same "level" as Events::trigger('post_system')
  • The CodeIgniter::$returnResponse property has been deprecated as it is no longer used.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@iRedds iRedds added refactor Pull requests that refactor code 4.4 labels May 24, 2023
@iRedds iRedds changed the title [4.4] feature: a single point of sending the Response. [4.4] refactor: a single point of sending the Response. May 24, 2023
@iRedds
iRedds force-pushed the sending-response branch from c91589a to 9f67962 Compare May 24, 2023 10:55
@iRedds

iRedds commented May 24, 2023

Copy link
Copy Markdown
Collaborator Author

I'm a bit surprised that psalm can't find the Tests\Support\Controllers\Popcorn class.
Moreover, he has no claims to the same class from the neighboring test.

@kenjis

kenjis commented Jun 3, 2023

Copy link
Copy Markdown
Member

I don't know why but rarely Psalm reports errors that cannot reproduce.
I cannot reproduce the following error:

Run vendor/bin/psalm
Target PHP version: 7.4 (inferred from composer.json).
Scanning files...
Analyzing files...

░░░░░░░░░░░░░░░░░░░░░░

ERROR: UndefinedClass - tests/system/CodeIgniterTest.php:141:33 - Class, interface or enum named Tests\Support\Controllers\Popcorn does not exist (see https://psalm.dev/019)
        $routes->set404Override('Tests\Support\Controllers\Popcorn::pop');

https://github.com/codeigniter4/CodeIgniter4/actions/runs/5067800693/jobs/9099299107?pr=7519

And I reran the check, it passed.

Comment thread user_guide_src/source/changelogs/v4.4.0.rst Outdated
Co-authored-by: kenjis <kenji.uui@gmail.com>
@kenjis
kenjis merged commit 74f9b58 into codeigniter4:4.4 Jun 6, 2023
@kenjis

kenjis commented Jun 6, 2023

Copy link
Copy Markdown
Member

@iRedds Thank you!

@iRedds
iRedds deleted the sending-response branch June 6, 2023 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Pull requests that refactor code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants