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 XML or other response renderer header are not set #9699

Closed
wants to merge 1 commit into from

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Feb 4, 2016

Eg causes http://demo.piwik.org/index.php?module=API&method=Live.getLastVisitsDetails&format=XML&idSite=7&period=month&date=2016-01-12&expanded=1&token_auth=&filter_limit=10 to be returned as plain text.

Problem: Within the response renderer, in handleDataTable, after the API request was executed and the correct header already set, we perform another API request by https://github.com/piwik/piwik/blob/master/plugins/Intl/DateTimeFormatProvider.php#L110 which then sets a plain header.

Quick workaround is to just send it again. Possibly better workaround is to not set a header when original render is used. Or to only set it when serialized=1 here: https://github.com/piwik/piwik/blob/master/plugins/API/Renderer/Original.php#L53
We could change it to

        if ($this->shouldSerialize()) {
            Common::sendHeader('Content-Type: text/plain; charset=utf-8');
        }

Eg causes http://demo.piwik.org/index.php?module=API&method=Live.getLastVisitsDetails&format=XML&idSite=7&period=month&date=2016-01-12&expanded=1&token_auth=&filter_limit=10 to be returned as plain text.

Problem: Within the response renderer, in `handleDataTable`, after the API request was executed and the correct header already set, we perform another API request by https://github.com/piwik/piwik/blob/master/plugins/Intl/DateTimeFormatProvider.php#L110 which then sets a plain header.

Quick workaround is to just send it again. Possibly better workaround is to not set a header when `original` render is used. Or to only set it when `serialized=1` here: https://github.com/piwik/piwik/blob/master/plugins/API/Renderer/Original.php#L53  
We could change it to 
```php
        if ($this->shouldSerialize()) {
            Common::sendHeader('Content-Type: text/plain; charset=utf-8');
        }
```
@tsteur tsteur added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Feb 4, 2016
@tsteur tsteur added this to the 2.16.0 milestone Feb 4, 2016
@tsteur
Copy link
Member Author

tsteur commented Feb 4, 2016

I'd be happy to issue another PR for the other fix

@tsteur
Copy link
Member Author

tsteur commented Feb 4, 2016

Closing this one in favour of #9700

@tsteur tsteur closed this Feb 4, 2016
@tsteur tsteur deleted the export_format_bug branch February 4, 2016 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant