Page MenuHomePhabricator

PHP Notice: ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush on Special:UploadStash
Closed, ResolvedPublic

Description

Since I upgraded to MediaWiki 1.30, I get those notices:

PHP Notice:  ob_end_flush(): failed to delete and flush buffer. No buffer to delete or flush in mediawiki-1.30.0/includes/filerepo/FileRepo.php on line 1612

This happens when someone access Special:UploadStash when a file failed to upload due to a warning.

Looking at the code, it seems to be caused by the code added for T172851

Using PHP 7.0.19-1

Event Timeline

Restricted Application added projects: Commons, Multimedia. · View Herald TranscriptFeb 5 2018, 9:11 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

ob_start is also added in the same patch in the same function. The buffer shouldn't just be gone.

This is caused by ob_end_clean() called in HTTPFileStreamer::resetOutputBuffers(), which is called from

HTTPFileStreamer::resetOutputBuffers() <- HTTPFileStreamer::stream() <- FileBackendStore::doStreamFile() <- FileBackendStore::streamFile() <- FileRepo::streamFileWithStatus()

Top-most caller (streamFileWithStatus) tries to do ob_end_flush() after this ob_end_clean(), resulting in warning (because ob_end_clean disabled the buffer).

Change 423350 had a related patch set uploaded (by Edward Chernenko; owner: Edward Chernenko):
[mediawiki/core@master] Fix warning "ob_end_flush(): failed to delete and flush buffer" during uploads

https://gerrit.wikimedia.org/r/423350

Patch submitted.

Note that resetOutputBuffers() is not always called (it's just a default callback, another callback can be specified instead), so I'm not removing the ob_clean_end() completely. Instead we use ob_get_status() to determine if the buffer exists.

Does resetOutputBuffers() literally undo T172851? If so, we'd better find an alternative workaround for that task (like what Anomie and Tgr suggested) rather than depending more and more on a global state.

Krinkle moved this task from Backlog to Core on the MW-1.31-release board.Apr 18 2018, 6:08 PM

Change 423350 merged by jenkins-bot:
[mediawiki/core@master] Fix warning "ob_end_flush(): failed to delete and flush buffer" during uploads

https://gerrit.wikimedia.org/r/423350

Change 434609 had a related patch set uploaded (by Krinkle; owner: Edward Chernenko):
[mediawiki/core@REL1_31] Fix warning "ob_end_flush(): failed to delete and flush buffer" during uploads

https://gerrit.wikimedia.org/r/434609

Change 434610 had a related patch set uploaded (by Krinkle; owner: Edward Chernenko):
[mediawiki/core@REL1_30] Fix warning "ob_end_flush(): failed to delete and flush buffer" during uploads

https://gerrit.wikimedia.org/r/434610

Krinkle closed this task as Resolved.May 22 2018, 10:11 PM
Krinkle claimed this task.

Change 434609 merged by jenkins-bot:
[mediawiki/core@REL1_31] Fix warning "ob_end_flush(): failed to delete and flush buffer" during uploads

https://gerrit.wikimedia.org/r/434609

Change 434610 merged by jenkins-bot:
[mediawiki/core@REL1_30] Fix warning "ob_end_flush(): failed to delete and flush buffer" during uploads

https://gerrit.wikimedia.org/r/434610