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

Bug: $format in ResourceController is ignored #2828

Closed
rmilecki opened this issue Apr 15, 2020 · 2 comments
Closed

Bug: $format in ResourceController is ignored #2828

rmilecki opened this issue Apr 15, 2020 · 2 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@rmilecki
Copy link

Describe the bug
CodeIgniter\RESTful\ResourceController allows (according to the documentation and source code) specifying output format by setting protected $format to xml or json. There is even ResourceController::setFormat helper.

It doesn't work however as $format seems to be ignored.

In practice calling ResponseTrait::respond results in calling ResponseTrait::format which negotiates output format:

$format = $this->request->negotiate('media', $config->supportedResponseFormats, false);

E.g. I get XML when opening page in web browser and JSON when using CLI curl.

CodeIgniter 4 version
4.0.2

Affected module(s)
ResourceController and ResponseTrait::format.

Expected behavior, and steps to reproduce if appropriate

  1. Setting protected $format = 'xml'; should always generate XML response
  2. Setting protected $format = 'json'; should always generate JSON response
@rmilecki rmilecki added the bug Verified issues on the current code behavior or pull requests that will fix them label Apr 15, 2020
@samsonasik
Copy link
Member

could you try latest dev-develop?

php builds development
composer update

@michalsn
Copy link
Member

Already fixed.

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

No branches or pull requests

3 participants