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

Fixes #15046 #15390

Merged
merged 4 commits into from
Dec 19, 2017
Merged

Fixes #15046 #15390

merged 4 commits into from
Dec 19, 2017

Conversation

dmirogin
Copy link
Contributor

Q A
Is bugfix? no
New feature? yes
Breaks BC? I think worth mentioning this in upgrade
Tests pass? yes
Fixed issues #15046

* @param int $line
* @return HeadersAlreadySentException
*/
public static function make($file, $line)
Copy link
Member

Choose a reason for hiding this comment

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

Why not using constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dont want to change constructor params.

Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just prefer this style. But in this case it's redundant.

@samdark samdark added the type:bug Bug label Dec 19, 2017
@samdark samdark added the pr:request for unit tests Unit tests are needed. label Dec 19, 2017
@yii-bot
Copy link

yii-bot commented Dec 19, 2017

Thank you for putting effort in the improvement of the Yii framework.
We have reviewed your pull request.

In order for the framework and your solution to remain stable in the future, we have a unit test requirement in place. Therefore we can only accept your pull request if it is covered by unit tests.

Could you add these please?

Thanks!

P.S. If you have any questions about the creation of unit tests? Don't hesitate to ask for support. More information about unit tests

This is an automated comment, triggered by adding the label pr:request for unit tests.

@dmirogin
Copy link
Contributor Author

dmirogin commented Dec 19, 2017

I don't know how to test it, because cli SAPI doesn't support headers access.

@samdark samdark removed the pr:request for unit tests Unit tests are needed. label Dec 19, 2017
@samdark
Copy link
Member

samdark commented Dec 19, 2017

Right. Let's skip it this time.

@samdark samdark merged commit 28e7f31 into yiisoft:master Dec 19, 2017
@samdark
Copy link
Member

samdark commented Dec 19, 2017

Merged. Thanks!

@SilverFire SilverFire added this to the 2.0.14 milestone Dec 21, 2017
if (headers_sent()) {
return;
if (headers_sent($file, $line)) {
throw new HeadersAlreadySentException($file, $line);
Copy link
Contributor

@lubosdz lubosdz Feb 19, 2018

Choose a reason for hiding this comment

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

This is a serious BC break - disallows setting flexibly custom headers anywhere in the code, e.g. when downloading files. Should be reverted to provide more flexibility rather than restricting & forcing users to set headers via Response object. Previous code was OK.

BTW - setting custom headers in response is also not so intuitive, since $_headers is private property (should not be public ?) and there is also not setter like setHeader(name, value) or massive setter setHeaders([]).

Copy link
Member

Choose a reason for hiding this comment

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

You were not able to set them anyway. It was just silently ignored.

Copy link
Contributor

Choose a reason for hiding this comment

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

We used to set various custom headers directly e.g.
header('Content-Type: application/octet-stream', false);
Now everybody who used to set inline headers will get Exception. With already 14th branch release there might be heaps of code to be refactored :-( It would be better to leave such a BC change for 2.1.X. I am not sure what you mean not able to set them anyway - it was possible via $response->getHeaders()->add(), right? But we did not use it coz it's sometime easier to write native PHP headers with second replace option.

Copy link
Member

@samdark samdark Feb 19, 2018

Choose a reason for hiding this comment

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

If there's now an exception than these headers weren't working well before i.e. some headers were set but not sent. That's clearly an error that should be fixed anyway. It was hidden before but it doesn't mean that it worked correctly. Quite the opposite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants