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: Response::download() causes TypeError #6361

Merged
merged 1 commit into from
Aug 13, 2022

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Aug 9, 2022

Description
Fixes #6358

  • never cache DownloadResponse/RedirectResponse
  • add null check for $this->response->getBody()

How to Test

<?php

namespace App\Controllers;

class Home extends BaseController
{
    public function index()
    {
        return $this->response->download('some.txt', 'some text', true);
    }
}

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 Aug 9, 2022
@MGatner
Copy link
Member

MGatner commented Aug 9, 2022

Should RedirectResponse be checked? Also, I think null is an acceptable body for some API responses - we might need to check or cast that.

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.

See previous comments.

@nicojmb
Copy link

nicojmb commented Aug 9, 2022

Hi, same problem here, just testedkenjis fix and works fine.

TypeError
CodeIgniter\CodeIgniter::displayPerformanceMetrics(): Argument #1 ($output) must be of type string, null given, called in .../CodeIgniter4/system/CodeIgniter.php on line 500
@kenjis
Copy link
Member Author

kenjis commented Aug 10, 2022

Changed the implementation.

@kenjis kenjis requested a review from MGatner August 10, 2022 10:40
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.

Thank you!

@MGatner
Copy link
Member

MGatner commented Aug 10, 2022

Any ideas how this made it through tests to release?

@MGatner MGatner changed the base branch from develop to master August 13, 2022 00:07
@MGatner MGatner changed the base branch from master to develop August 13, 2022 00:07
@MGatner MGatner merged commit 85e6421 into codeigniter4:develop Aug 13, 2022
@kenjis kenjis deleted the fix-response-download branch May 14, 2023 02:16
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: Force File Download error in the latest version (4.2.3)
3 participants