Index: trunk/phase3/includes/upload/UploadFromUrl.php |
— | — | @@ -96,6 +96,13 @@ |
97 | 97 | fclose( $this->mCurlDestHandle ); |
98 | 98 | unset( $this->mCurlDestHandle ); |
99 | 99 | |
| 100 | + global $wgMaxUploadSize; |
| 101 | + if ( $this->mFileSize > $wgMaxUploadSize ) { |
| 102 | + # Just return an ok, so that the regular verifications can handle |
| 103 | + # the file-too-large error |
| 104 | + return Status::newGood(); |
| 105 | + } |
| 106 | + |
100 | 107 | return $status; |
101 | 108 | } |
102 | 109 | |
Index: trunk/phase3/includes/upload/UploadBase.php |
— | — | @@ -29,8 +29,10 @@ |
30 | 30 | const FILETYPE_MISSING = 8; |
31 | 31 | const FILETYPE_BADTYPE = 9; |
32 | 32 | const VERIFICATION_ERROR = 10; |
| 33 | + # HOOK_ABORTED is the new name of UPLOAD_VERIFICATION_ERROR |
33 | 34 | const UPLOAD_VERIFICATION_ERROR = 11; |
34 | 35 | const HOOK_ABORTED = 11; |
| 36 | + const FILE_TOO_LARGE = 12; |
35 | 37 | |
36 | 38 | const SESSION_VERSION = 2; |
37 | 39 | const SESSION_KEYNAME = 'wsUploadData'; |
— | — | @@ -199,6 +201,14 @@ |
200 | 202 | if( $this->isEmptyFile() ) { |
201 | 203 | return array( 'status' => self::EMPTY_FILE ); |
202 | 204 | } |
| 205 | + |
| 206 | + /** |
| 207 | + * Honor $wgMaxUploadSize |
| 208 | + */ |
| 209 | + global $wgMaxUploadSize; |
| 210 | + if( $this->mFileSize > $wgMaxUploadSize ) { |
| 211 | + return array( 'status' => self::FILE_TOO_LARGE ); |
| 212 | + } |
203 | 213 | |
204 | 214 | /** |
205 | 215 | * Look at the contents of the file; if we can recognize the |
Index: trunk/phase3/includes/api/ApiUpload.php |
— | — | @@ -154,6 +154,9 @@ |
155 | 155 | case UploadBase::EMPTY_FILE: |
156 | 156 | $this->dieUsage( 'The file you submitted was empty', 'empty-file' ); |
157 | 157 | break; |
| 158 | + case UploadBase::FILE_TOO_LARGE: |
| 159 | + $this->dieUsage( 'The file you submitted was too large', 'file-too-large' ); |
| 160 | + break; |
158 | 161 | case UploadBase::FILETYPE_MISSING: |
159 | 162 | $this->dieUsage( 'The file is missing an extension', 'filetype-missing' ); |
160 | 163 | break; |
Index: trunk/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -365,7 +365,7 @@ |
366 | 366 | /** |
367 | 367 | * Show the upload form with error message, but do not stash the file. |
368 | 368 | * |
369 | | - * @param $message String |
| 369 | + * @param $message HTML string |
370 | 370 | */ |
371 | 371 | protected function showUploadError( $message ) { |
372 | 372 | $message = '<h2>' . wfMsgHtml( 'uploadwarning' ) . "</h2>\n" . |
— | — | @@ -522,8 +522,11 @@ |
523 | 523 | |
524 | 524 | /** Statuses that require reuploading **/ |
525 | 525 | case UploadBase::EMPTY_FILE: |
526 | | - $this->showUploadForm( $this->getUploadForm( wfMsgHtml( 'emptyfile' ) ) ); |
| 526 | + $this->showUploadError( wfMsgHtml( 'emptyfile' ) ); |
527 | 527 | break; |
| 528 | + case UploadBase::FILESIZE_TOO_LARGE: |
| 529 | + $this->showUploadError( wfMsgHtml( 'largefileserver' ) ); |
| 530 | + break; |
528 | 531 | case UploadBase::FILETYPE_BADTYPE: |
529 | 532 | $finalExt = $details['finalExt']; |
530 | 533 | $this->showUploadError( |
— | — | @@ -744,6 +747,7 @@ |
745 | 748 | */ |
746 | 749 | protected function getSourceSection() { |
747 | 750 | global $wgLang, $wgUser, $wgRequest; |
| 751 | + global $wgMaxUploadSize; |
748 | 752 | |
749 | 753 | if ( $this->mSessionKey ) { |
750 | 754 | return array( |
— | — | @@ -783,13 +787,16 @@ |
784 | 788 | 'help' => wfMsgExt( 'upload-maxfilesize', |
785 | 789 | array( 'parseinline', 'escapenoentities' ), |
786 | 790 | $wgLang->formatSize( |
787 | | - wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ) |
| 791 | + wfShorthandToInteger( min( |
| 792 | + wfShorthandToInteger( |
| 793 | + ini_get( 'upload_max_filesize' ) |
| 794 | + ), $wgMaxUploadSize |
| 795 | + ) ) |
788 | 796 | ) |
789 | 797 | ) . ' ' . wfMsgHtml( 'upload_source_file' ), |
790 | 798 | 'checked' => $selectedSourceType == 'file', |
791 | 799 | ); |
792 | 800 | if ( $canUploadByUrl ) { |
793 | | - global $wgMaxUploadSize; |
794 | 801 | $descriptor['UploadFileURL'] = array( |
795 | 802 | 'class' => 'UploadSourceField', |
796 | 803 | 'section' => 'source', |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -111,6 +111,7 @@ |
112 | 112 | displays incorrect tabs |
113 | 113 | * (bug 23190) Improved math representation for text browsers. |
114 | 114 | * (bug 22015) Improved upload-by-url error handling and error display |
| 115 | +* (bug 17941) $wgMaxUploadSize is now honored by all upload sources |
115 | 116 | |
116 | 117 | === API changes in 1.17 === |
117 | 118 | * (bug 22738) Allow filtering by action type on query=logevent |