Page MenuHomePhabricator

PHP Warning from /w/thumb.php: "Cannot modify header information - headers already sent"
Open, HighPublic

Description

Error

Request URL: commonswiki thumbnail proxy
Request ID: XPjEdQpAMFgAABuWMJYAAAAY

message
ErrorException from line 649 of /srv/mediawiki/php-1.34.0-wmf.8/thumb.php: PHP Warning: Cannot modify header information - headers already sent
ErrorException from line 638 of /srv/mediawiki/php-1.34.0-wmf.8/thumb.php: PHP Warning: Cannot modify header information - headers already sent
ErrorException from line 675 of /srv/mediawiki/php-1.34.0-wmf.8/thumb.php: PHP Warning: Cannot modify header information - headers already sent
ErrorException from line 637 of /srv/mediawiki/php-1.34.0-wmf.8/thumb.php: PHP Warning: Cannot modify header information - headers already sent
trace
#0 /srv/mediawiki/php-1.34.0-wmf.8/thumb.php(649): MWExceptionHandler::handleError(integer, string, string, integer, array, array)
#1 /srv/mediawiki/php-1.34.0-wmf.8/thumb.php(326): wfThumbError(integer, string, NULL, array)
#2 /srv/mediawiki/php-1.34.0-wmf.8/thumb.php(38): wfStreamThumb(array)
#3 /srv/mediawiki/w/thumb.php(3): include(string)
#4 {main}

Impact

Response might be corrupt.

Notes

Started happening today on wmf.8.

Details

Related Gerrit Patches:

Event Timeline

Krinkle created this task.Jun 6 2019, 11:27 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 6 2019, 11:27 AM
Restricted Application added a project: Commons. · View Herald TranscriptJun 6 2019, 11:28 AM
zeljkofilipin triaged this task as Unbreak Now! priority.Jun 6 2019, 11:49 AM
zeljkofilipin added a subscriber: zeljkofilipin.

Train blockers are unbreak now priority.

Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptJun 6 2019, 11:49 AM
Reedy lowered the priority of this task from Unbreak Now! to High.Jun 6 2019, 1:08 PM
Reedy added a subscriber: Reedy.

Looking at logstash over the last 24H... There was no results in the last 1H for this

This isn't a train blocker

Paladox added a subscriber: Paladox.Jun 6 2019, 1:09 PM
Tgr added a subscriber: Tgr.Jun 6 2019, 1:10 PM

We should probably use WebResponse which can log where the headers were sent.

Change 514732 had a related patch set uploaded (by Gergő Tisza; owner: Gergő Tisza):
[mediawiki/core@master] Log headers sent errors more usefully in thumb.php

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

Change 514732 merged by jenkins-bot:
[mediawiki/core@master] Log headers sent errors more usefully in thumb.php

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

Ramsey-WMF moved this task from Untriaged to Tracking on the Multimedia board.Jun 7 2019, 8:15 PM

Change 516495 had a related patch set uploaded (by Krinkle; owner: Gergő Tisza):
[mediawiki/core@wmf/1.34.0-wmf.8] Log headers sent errors more usefully in thumb.php

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

Change 516495 merged by jenkins-bot:
[mediawiki/core@wmf/1.34.0-wmf.8] Log headers sent errors more usefully in thumb.php

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

Mentioned in SAL (#wikimedia-operations) [2019-06-12T18:15:55Z] <krinkle@deploy1001> Synchronized php-1.34.0-wmf.8/thumb.php: T225197 / 06b631fae5 (duration: 00m 47s)

Krinkle renamed this task from "PHP Warning: Cannot modify header information - headers already sent" from /w/thumb.php to PHP Warning from /w/thumb.php: "Cannot modify header information - headers already sent".Jun 12 2019, 6:17 PM
Krinkle removed a project: Patch-For-Review.
Krinkle added a comment.EditedJul 30 2019, 4:56 PM

New information from this error from the above debug instrumentation:

PHP Warning: Cannot modify header information - headers already sent by (output started at /srv/mediawiki/php-1.34.0-wmf.15/includes/libs/http/MultiHttpClient.php:416)

#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.34.0-wmf.15/thumb.php(646): header(string)
#2 /srv/mediawiki/php-1.34.0-wmf.15/thumb.php(330): wfThumbError(integer, string, NULL, array)
#3 /srv/mediawiki/php-1.34.0-wmf.15/thumb.php(38): wfStreamThumb(array)
PHP Warning: Cannot modify header information - headers already sent by (output started at /srv/mediawiki/php-1.34.0-wmf.15/includes/libs/http/MultiHttpClient.php:416)

#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.34.0-wmf.15/thumb.php(683): header(string)
#2 /srv/mediawiki/php-1.34.0-wmf.15/thumb.php(330): wfThumbError(integer, string, NULL, array)
#3 /srv/mediawiki/php-1.34.0-wmf.15/thumb.php(38): wfStreamThumb(array)

So looks like MultiHttpClient might be at fault?

mmodell changed the subtype of this task from "Task" to "Production Error".Aug 28 2019, 11:06 PM
daniel added a subscriber: daniel.Aug 29 2019, 10:42 PM

This seems to be a secondary error, triggered while trying to report another error. As far as I can tell from looking at the code for five minutes, this seems to be happening:

  • In line 321 of thumb.php, we call $status = $img->getRepo()->streamFileWithStatus( $thumbPath, $headers ) which tries to send the file, and starts generating output, but hits an error at some point.
  • $status->isOK() returns false in line 324, so wfThumbError() is called in 329.
  • wfThumbError() tries to set a header in line 645, which triggers "PHP Warning: Cannot modify header information"

Seems to me like wfThumbError() should not tried to send HTML output if output was already sent.
Also, we should probably log the original error somewhere, somehow. As far as I can tell, that doesn't happen at all.