(bug 18411) The upload form now also checks post_max_size (patch contributed by Enuka...
authorSiebrand Mazeland <siebrand@users.mediawiki.org>
Sun, 17 May 2009 19:23:12 +0000 (19:23 +0000)
committerSiebrand Mazeland <siebrand@users.mediawiki.org>
Sun, 17 May 2009 19:23:12 +0000 (19:23 +0000)
CREDITS
RELEASE-NOTES
includes/specials/SpecialUpload.php

diff --git a/CREDITS b/CREDITS
index c11574a..768df07 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -67,6 +67,7 @@ following names for their contribution to the product.
 * Daniel Arnold
 * Danny B.
 * Derk-Jan Hartman
+* Emufarmers
 * FunPika
 * Happy-melon
 * Jeremy Baron
index de6187b..2f80f48 100644 (file)
@@ -53,6 +53,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   Mediawiki Namespace, before checking the message files
 * (bug 18466) Add note or warning when overruling a move (semi-)protection
 * (bug 18342) insertTags works in edit summary box
+* (bug 18411) The upload form also checks post_max_size
 
 === Bug fixes in 1.16 ===
 
index 317402d..f234ccc 100644 (file)
@@ -1047,26 +1047,29 @@ wgUploadAutoFill = {$autofill};
                }
 
                # Get the maximum file size from php.ini as $wgMaxUploadSize works for uploads from URL via CURL only
-               # See http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize for possible values of upload_max_filesize
-               $val = trim( ini_get( 'upload_max_filesize' ) );
-               $last = strtoupper( ( substr( $val, -1 ) ) );
-               switch( $last ) {
-                       case 'G':
-                               $val2 = substr( $val, 0, -1 ) * 1024 * 1024 * 1024;
-                               break;
-                       case 'M':
-                               $val2 = substr( $val, 0, -1 ) * 1024 * 1024;
-                               break;
-                       case 'K':
-                               $val2 = substr( $val, 0, -1 ) * 1024;
-                               break;
-                       default:
-                               $val2 = $val;
+               # See http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes for possible values of upload_max_filesize and post_max_filesize
+               $max_sizes = array();
+               $max_sizes[] = trim( ini_get( 'upload_max_filesize' ) );
+               $max_sizes[] = trim( ini_get( 'post_max_size' ) );
+               foreach( $max_sizes as &$size) {
+                       $last = strtoupper( substr( $size, -1 ) );
+                       switch( $last ) {
+                               case 'G':
+                                       $size = substr( $size, 0, -1 ) * 1024 * 1024 * 1024;
+                                       break;
+                               case 'M':
+                                       $size = substr( $size, 0, -1 ) * 1024 * 1024;
+                                       break;
+                               case 'K':
+                                       $size = substr( $size, 0, -1 ) * 1024;
+                                       break;
+                       }
                }
-               $val2 = $wgAllowCopyUploads ? min( $wgMaxUploadSize, $val2 ) : $val2;
+               $val = min( $max_sizes[0], $max_sizes[1] );
+               $val = $wgAllowCopyUploads ? min( $wgMaxUploadSize, $val ) : $val;
                $maxUploadSize = '<div id="mw-upload-maxfilesize">' . 
                        wfMsgExt( 'upload-maxfilesize', array( 'parseinline', 'escapenoentities' ), 
-                               $wgLang->formatSize( $val2 ) ) .
+                               $wgLang->formatSize( $val ) ) .
                                "</div>\n";
 
                $sourcefilename = wfMsgExt( 'sourcefilename', array( 'parseinline', 'escapenoentities' ) );