Skip to content

[Debug] work-around https://bugs.php.net/61272 #11099

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

Merged
merged 1 commit into from
Jun 12, 2014

Conversation

nicolas-grekas
Copy link
Member

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #8703
License MIT

https://bugs.php.net/61272 is the real offender.
Using ob_end_flush() instead of ob_end_clean() is the fix.

@@ -99,8 +99,8 @@ public function handle(\Exception $exception)
$this->caughtOutput = false;
ob_start(array($this, 'catchOutput'));
$this->failSafeHandle($exception);
if (false === $this->caughtOutput) {
ob_end_clean();
while (false === $this->caughtOutput && ob_end_flush()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ob_end_flush actually sends the buffer whereas ob_end_clean doesn't?! is this change intended?

@nicolas-grekas
Copy link
Member Author

Yes: the handler returns '' so both are equivalent in this case

@Tobion
Copy link
Contributor

Tobion commented Jun 11, 2014

OK. The code is pretty hard to understand. $this->caughtOutput is sometimes int, sometimes string, sometimes false. I think the variable does not need to change type so often.

@nicolas-grekas
Copy link
Member Author

Patch updated, should be easier to understand


try {
call_user_func($this->handler, $exception);

if ($caughtOutput) {
$this->caughtOutput = $caughtOutput;
if ($caughtLength) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this if statement necessary? I don't see why

Copy link
Member Author

Choose a reason for hiding this comment

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

So do I :)

@Tobion
Copy link
Contributor

Tobion commented Jun 11, 2014

👍

ob_start(array($this, 'catchOutput'));
$this->failSafeHandle($exception);
if (false === $this->caughtOutput) {
ob_end_clean();
while (null === $this->caughtBuffer && ob_end_flush()) {
Copy link
Member

Choose a reason for hiding this comment

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

why is it a loop now ?

Copy link
Member Author

Choose a reason for hiding this comment

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

As locally I don't want to know anything about failSafeHandle(), several ob_start() could have been started somewhere else. This loop just closes all these potentially opened buffers. Fail-safe and defensive coding practice.

@romainneutron
Copy link
Contributor

👍

1 similar comment
@stof
Copy link
Member

stof commented Jun 12, 2014

👍

@fabpot fabpot merged commit cb8aff3 into symfony:2.5 Jun 12, 2014
fabpot added a commit that referenced this pull request Jun 12, 2014
…ekas)

This PR was merged into the 2.5 branch.

Discussion
----------

[Debug] work-around https://bugs.php.net/61272

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8703
| License       | MIT

https://bugs.php.net/61272 is the real offender.
Using ob_end_flush() instead of ob_end_clean() is the fix.

Commits
-------

cb8aff3 [Debug] work-around https://bugs.php.net/61272
@nicolas-grekas nicolas-grekas deleted the wo-61272 branch June 12, 2014 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants