Last modified: 2014-02-25 15:43:53 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T48836, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 46836 - PHP Notice: ob_end_clean(): failed to delete buffer zlib output compression in includes/resourceloader/ResourceLoader.php on line 602
PHP Notice: ob_end_clean(): failed to delete buffer zlib output compression i...
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
ResourceLoader (Other open bugs)
1.22.0
All All
: High normal (vote)
: 1.22.0 release
Assigned To: Marius Hoch
https://gerrit.wikimedia.org/r/#/c/57...
: code-update-regression
: 61359 (view as bug list)
Depends on:
Blocks: 39480
  Show dependency treegraph
 
Reported: 2013-04-03 07:54 UTC by Siebrand Mazeland
Modified: 2014-02-25 15:43 UTC (History)
9 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Siebrand Mazeland 2013-04-03 07:54:47 UTC
Observed very regularly in the logs of translatewiki.net after updating from 910c6d8 2013-04-02 11:04:11 +0000 to f9ce826 2013-04-03 07:37:56 +0000
Comment 1 Siebrand Mazeland 2013-04-03 08:00:34 UTC
I left a comment on https://gerrit.wikimedia.org/r/#/c/57227/1/includes/resourceloader/ResourceLoader.php
Comment 2 Andre Klapper 2013-04-08 14:43:50 UTC
Krinkle / Hoo: As you wrote / reviewed the patch that likely created this regression, could you take a look please?
Comment 3 Gerrit Notification Bot 2013-04-09 22:16:37 UTC
Related URL: https://gerrit.wikimedia.org/r/58429 (Gerrit Change Ida0e48931781be77327073dc4ed3966949f4b082)
Comment 4 Siebrand Mazeland 2013-04-09 22:34:40 UTC
Patch from comment 3 was merged.
Comment 5 David Taylor 2013-07-13 10:12:32 UTC
This change means I'm now seeing the 20-byte empty gzip bodies with 304 responses that this code is supposed to prevent.

I don't understand how it was supposed to work for ob_get_level() not equal to 0 or 1.

Consider the case where ob_get_level() starts at 2: ob_end_clean() will only be called once.

for ( $i = 0; $i < ob_get_level(); $i++ ) {
    ob_end_clean();
}

$i = 0;

$i < ob_get_level();      [0 < 2: true]
ob_end_clean(); 
$i++                      [$i = 1]


$i < ob_get_level();      [1 < 1: false]
Comment 6 Greg Grossmeier 2013-07-15 17:08:08 UTC
Marius: As Timo is probably pretty busy with VE things today, mind taking a look at this issue?
Comment 7 Gerrit Notification Bot 2013-07-19 01:27:36 UTC
Change 74570 had a related patch set uploaded by Hoo man:
Suppress notices while deleting output buffers

https://gerrit.wikimedia.org/r/74570
Comment 8 Krinkle 2013-07-19 01:29:43 UTC
(In reply to comment #5)
> This change means I'm now seeing the 20-byte empty gzip bodies with 304
> responses that this code is supposed to prevent.

I've been wondering what those 20-byte content-length were all about. I spotted it here and there over the past few weeks (wasn't really looking for content-length, but I sort-of noticed it in the corner of my eye when looking at something else).

Nice catch.
Comment 9 Krinkle 2013-07-19 16:45:16 UTC
(In reply to comment #7)
> Change 74570 had a related patch set uploaded by Hoo man:
> Suppress notices while deleting output buffers
> 
> https://gerrit.wikimedia.org/r/74570

Can you explain why caching the level is not a problem now? Aside from the warning suppression, this is exactly what I did a few months ago (back then just to optimise the code, not to fix anything in particular) and then I had to revert it as it caused this bug (bug 46836) and added an inline code comment about it, which you now removed.

In some (or many?) cases the level seems to go to zero in 1 call. So caching doesn't seem like a good choice.

(In reply to comment #5)
> This change means I'm now seeing the 20-byte empty gzip bodies with 304
> responses that this code is supposed to prevent.
> 
> I don't understand how it was supposed to work for ob_get_level() not equal
> to
> 0 or 1.
> 
> Consider the case where ob_get_level() starts at 2: ob_end_clean() will only
> be
> called once.
> 
> for ( $i = 0; $i < ob_get_level(); $i++ ) {
>     ob_end_clean();
> }
> 
> $i = 0;
> 
> $i < ob_get_level();      [0 < 2: true]
> ob_end_clean(); 
> $i++                      [$i = 1]
> 
> 
> $i < ob_get_level();      [1 < 1: false]



So it should just be <= instead of <, right?
Comment 10 Roan Kattouw 2013-07-19 18:45:45 UTC
(In reply to comment #9)
> So it should just be <= instead of <, right?
No. The problem is that $i increases while get_level() decreases at the same time. This is why caching get_level() changes the behavior to something that's arguably more correct.

Probably the best way to do this would be something like

while ( ob_get_level() > desired value ) { ob_end_clean(); }

Problem is I don't know enough about output buffering offhand to know what the desired value is. I *think* it's 0. Maybe it's 1. Who knows. Output buffering is magical.
Comment 11 Kevin Israel (PleaseStand) 2013-07-19 22:36:30 UTC
Is there a reason wfClearOutputBuffers() isn't used here?
Comment 12 Krinkle 2013-07-20 00:50:01 UTC
(In reply to comment #10)
> (In reply to comment #9)
> > So it should just be <= instead of <, right?
> No. The problem is that $i increases while get_level() decreases at the same
> time.

Right, it's obvious now that you pointed it out :)


(In reply to comment #11)
> Is there a reason wfClearOutputBuffers() isn't used here?

Looks like a good candidate at first sight.

HISTORY shows that this was introduced/updated for a similar use case:
> * (bug 8148) Handle non-removable output buffers gracefully when cleaning
>   buffers for HTTP 304 responses, StreamFile, and Special:Export.
>   Duplicated code merged into wfResetOutputBuffers() and wfClearOutputBuffers()

OutputPage::checkLastModified
> $this->getRequest()->response()->header( "HTTP/1.1 304 Not Modified" );
> wfClearOutputBuffers();
Comment 13 Andre Klapper 2013-07-22 09:58:16 UTC
Patch in comment 7 got merged, not closing as I guess there is more work to do here according to comment 11.
Comment 14 Marius Hoch 2013-07-22 11:04:08 UTC
(In reply to comment #13)
> Patch in comment 7 got merged, not closing as I guess there is more work to
> do
> here according to comment 11.

The patch (which uses wfClearOutputBuffers mentioned in comment 11 now) hasn't been merged yet... if it gets merged I guess we can close this bug.
Comment 15 Andre Klapper 2013-08-13 13:10:16 UTC
Patch still waiting for merge...
Comment 16 Krinkle 2013-09-18 16:31:55 UTC
(In reply to comment #0)
> Observed very regularly in the logs of translatewiki.net after updating from
> 910c6d8 2013-04-02 11:04:11 +0000 to f9ce826 2013-04-03 07:37:56 +0000

Per Nikerabbit, they no longer appear in recent logs.
Comment 17 Gerrit Notification Bot 2013-09-18 17:01:22 UTC
Change 74570 merged by jenkins-bot:
Use wfResetOutputBuffers in ResourceLoader

https://gerrit.wikimedia.org/r/74570
Comment 18 Andre Klapper 2014-02-25 15:43:53 UTC
*** Bug 61359 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links