From: Bartosz DziewoƄski Date: Mon, 16 Apr 2018 16:39:24 +0000 (+0200) Subject: ImportStreamSource: Replace magic numbers with constants X-Git-Tag: 1.34.0-rc.0~5690^2 X-Git-Url: http://git.cyclocoop.org/data/Luca_Pacioli_%28Gemaelde%29.jpeg?a=commitdiff_plain;h=9c881ed4da85377c5d181966de1976f35c1a193f;p=lhc%2Fweb%2Fwiklou.git ImportStreamSource: Replace magic numbers with constants https://secure.php.net/manual/en/features.file-upload.errors.php Also improve code comments. Change-Id: I3bbe02f5cce39352659b33caba10e40afc5fe34a --- diff --git a/includes/import/ImportStreamSource.php b/includes/import/ImportStreamSource.php index cf382e4804..ebac200a4a 100644 --- a/includes/import/ImportStreamSource.php +++ b/includes/import/ImportStreamSource.php @@ -74,20 +74,21 @@ class ImportStreamSource implements ImportSource { } if ( !empty( $upload['error'] ) ) { switch ( $upload['error'] ) { - case 1: - # The uploaded file exceeds the upload_max_filesize directive in php.ini. + case UPLOAD_ERR_INI_SIZE: + // The uploaded file exceeds the upload_max_filesize directive in php.ini. return Status::newFatal( 'importuploaderrorsize' ); - case 2: - # The uploaded file exceeds the MAX_FILE_SIZE directive that - # was specified in the HTML form. + case UPLOAD_ERR_FORM_SIZE: + // The uploaded file exceeds the MAX_FILE_SIZE directive that + // was specified in the HTML form. + // FIXME This is probably never used since that directive was removed in 8e91c520? return Status::newFatal( 'importuploaderrorsize' ); - case 3: - # The uploaded file was only partially uploaded + case UPLOAD_ERR_PARTIAL: + // The uploaded file was only partially uploaded return Status::newFatal( 'importuploaderrorpartial' ); - case 6: - # Missing a temporary folder. + case UPLOAD_ERR_NO_TMP_DIR: + // Missing a temporary folder. return Status::newFatal( 'importuploaderrortemp' ); - # case else: # Currently impossible + // Other error codes get the generic 'importnofile' error message below } }