Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CodeIgniter::run() doesn't respect $returnResponse #6737

Merged

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Oct 22, 2022

Description
Fixes #6650

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

@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Oct 22, 2022
@kenjis kenjis changed the title fix: $returnResponse in CodeIgniter::run() may not return Response fix: CodeIgniter::run() doesn't respect $returnResponse Oct 22, 2022
system/CodeIgniter.php Outdated Show resolved Hide resolved
system/CodeIgniter.php Outdated Show resolved Hide resolved
system/CodeIgniter.php Outdated Show resolved Hide resolved
if ($this->returnRespose) {
return $this->response;
}

$this->sendResponse();

$this->callExit(EXIT_SUCCESS);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR, but is this callExit() necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure - maybe just to enforce a "never return" condition?

Copy link
Member

@paulbalandan paulbalandan Oct 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you will add @phpstan-return never to protected function callExit, then phpstan correctly flags that the return; below will not be reached. So, this must be a bug?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the return is there because MockCodeIgniter prevents the actual exit statement. Still, this is a bad set up, and we should probably get rid of the exit altogether and just have the whole stack return cleanly.

Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
@kenjis kenjis force-pushed the fix-CodeIgniter-run-returnResponse branch from 54b9d3a to 59c076f Compare October 23, 2022 02:37
Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see if @AmitSonkhiya can test this.

system/CodeIgniter.php Outdated Show resolved Hide resolved
Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, I would like to see another tester if anyone is up for it.

@kenjis kenjis merged commit 76e2dac into codeigniter4:develop Oct 26, 2022
@kenjis kenjis deleted the fix-CodeIgniter-run-returnResponse branch October 26, 2022 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: sendResponse doesn't respect returnResponse parameter in codeigniter.php
5 participants