Page MenuHomePhabricator

PHP Warning: fclose() expects parameter 1 to be resource, boolean given
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error

MediaWiki version: 1.36.0-wmf.14

message
PHP Warning: fclose() expects parameter 1 to be resource, boolean given
exception.trace
#0 [internal function]: MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /srv/mediawiki/php-1.36.0-wmf.14/includes/upload/UploadBase.php(458): fclose(boolean)
#2 /srv/mediawiki/php-1.36.0-wmf.14/includes/upload/UploadBase.php(551): UploadBase->verifyMimeType(NULL)
#3 /srv/mediawiki/php-1.36.0-wmf.14/includes/upload/UploadBase.php(482): UploadBase->verifyPartialFile()
#4 /srv/mediawiki/php-1.36.0-wmf.14/includes/upload/UploadBase.php(390): UploadBase->verifyFile()
#5 /srv/mediawiki/php-1.36.0-wmf.14/includes/api/ApiUpload.php(610): UploadBase->verifyUpload()
#6 /srv/mediawiki/php-1.36.0-wmf.14/includes/api/ApiUpload.php(87): ApiUpload->verifyUpload()
#7 /srv/mediawiki/php-1.36.0-wmf.14/includes/api/ApiMain.php(1572): ApiUpload->execute()
#8 /srv/mediawiki/php-1.36.0-wmf.14/includes/api/ApiMain.php(552): ApiMain->executeAction()
#9 /srv/mediawiki/php-1.36.0-wmf.14/includes/api/ApiMain.php(523): ApiMain->executeActionWithErrorHandling()
#10 /srv/mediawiki/php-1.36.0-wmf.14/api.php(90): ApiMain->execute()
#11 /srv/mediawiki/php-1.36.0-wmf.14/api.php(45): wfApiMain()
#12 /srv/mediawiki/w/api.php(3): require(string)
#13 {main}

Impact

Notes

A small bunch of these (about 10?) happened right after moving train to group2.

Details

Request ID
fa659ee7-2e42-470f-8c2a-ce187a06055a
Request URL
https://commons.wikimedia.org/w/api.php

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Krinkle updated the task description. (Show Details)
Krinkle edited Stack Trace. (Show Details)
Krinkle moved this task from Untriaged to Oct 2020 on the Wikimedia-production-error board.

This looks like a file that get's lost during upload and can't be found in the temporary upload folder any more. The stack trace points to an fclose() in UploadBase::verifyMimeType(). But touching this method won't get rid of the error. There are many more places that try to open and read the same file later in the process.

I'm not sure how to fix this, or if it's even possible. The only thing the code could do about a missing file is to error out anyway.

Umherirrender subscribed.

The code is:

				$fp = fopen( $this->mTempPath, 'rb' );
				$chunk = fread( $fp, 256 );
				fclose( $fp );

Would not fread fail before fclose can fail if fopen returns false? Wonder why it fails on the close and not on read.

Change 667971 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] UploadBase: fopen can return false

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

Change 667971 merged by jenkins-bot:
[mediawiki/core@master] UploadBase: fopen can return false

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