http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95681
Revision: 95681
Author: neilk
Date: 2011-08-29 17:56:56 +0000 (Mon, 29 Aug 2011)
Log Message:
-----------
MFT of r79749 - needed to make other fixes for fatals in UploadStash work
Modified Paths:
--------------
branches/wmf/1.17wmf1/RELEASE-NOTES
branches/wmf/1.17wmf1/includes/DefaultSettings.php
branches/wmf/1.17wmf1/includes/specials/SpecialUpload.php
branches/wmf/1.17wmf1/includes/upload/UploadBase.php
branches/wmf/1.17wmf1/includes/upload/UploadFromFile.php
branches/wmf/1.17wmf1/includes/upload/UploadFromStash.php
branches/wmf/1.17wmf1/includes/upload/UploadFromUrl.php
Property Changed:
----------------
branches/wmf/1.17wmf1/RELEASE-NOTES
branches/wmf/1.17wmf1/includes/DefaultSettings.php
branches/wmf/1.17wmf1/includes/specials/SpecialUpload.php
branches/wmf/1.17wmf1/includes/upload/UploadBase.php
branches/wmf/1.17wmf1/includes/upload/UploadFromFile.php
Modified: branches/wmf/1.17wmf1/RELEASE-NOTES
===================================================================
--- branches/wmf/1.17wmf1/RELEASE-NOTES 2011-08-29 17:31:47 UTC (rev 95680)
+++ branches/wmf/1.17wmf1/RELEASE-NOTES 2011-08-29 17:56:56 UTC (rev 95681)
@@ -23,6 +23,8 @@
a lot of outstanding bugs, cleanup the code quality, and make it easier to
use. Notably, you can now run upgrades from the web without having to move
LocalSettings.php. The specific bugs are listed below in the general notes.
+* $wgMaxUploadSize may now be set to an array to specify the upload size limit
+ per upload type.
=== Configuration changes in 1.17 ===
* DatabaseFunctions.php that was needed for compatibility with pre-1.3
Property changes on: branches/wmf/1.17wmf1/RELEASE-NOTES
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/RELEASE-NOTES:51646
/branches/REL1_17/extensions/RELEASE-NOTES:81654
/branches/REL1_17/phase3/RELEASE-NOTES:81654
/branches/new-installer/phase3/RELEASE-NOTES:43664-66004
/branches/sqlite/RELEASE-NOTES:58211-58321
/branches/wmf/1.16wmf4/RELEASE-NOTES:67177,69199,76243,77266
/branches/wmf-deployment/RELEASE-NOTES:60970
/trunk/extensions/RELEASE-NOTES:78893,78897,78909,82404
/trunk/phase3/HISTORY:79860,80620
/trunk/phase3/RELEASE-NOTES:78893,78897,78909,78990,79166,79324,79454-79456,79536,79727,79733,79746,79773-79774,79844,80109,80113,80163,80222-80223,80322,80324,80326,80328,80339,80350-80351,80355,80358,80362-80363,80371,80442,80475,80492,80495,80540,80554,80575,80608,80620,80656,80666,80679,80685,80694,80728,80765,80813,80815,80841,81121,81124,81177,81186-81187,81197,81209-81211,81215,81238,81246,81262,81264,81430,81488,81496,81548,81554,81561,81589,81600,81611,81620,81622,81640,81648,81650-81652,82000,82022,82155-82156,82191,82193,82200,82203,82218,82297,82312,82337,82404,82408-82409,82453,82456-82458,82460,82465,82473-82474,82478,82482,82486,82513,82518,82530,82572,82608,82696,82810,82813-82815,82818,82836,82853,82858,83061,83067,83114,83270,83284,83374,83390,83392,83402-83403,83410-83411,83420,83461,83463,83583,83586-83587,83610,83716,83764,83787,83798,83813,83817,83866,83876,83979,84118,84228,84459,84729,84820,84985,85140,85152,85194,85377,85555,85583,86100,86121,86130,86142,86146,86183,86210
+ /branches/REL1_15/phase3/RELEASE-NOTES:51646
/branches/REL1_17/extensions/RELEASE-NOTES:81654
/branches/REL1_17/phase3/RELEASE-NOTES:81654
/branches/new-installer/phase3/RELEASE-NOTES:43664-66004
/branches/sqlite/RELEASE-NOTES:58211-58321
/branches/wmf/1.16wmf4/RELEASE-NOTES:67177,69199,76243,77266
/branches/wmf-deployment/RELEASE-NOTES:60970
/trunk/extensions/RELEASE-NOTES:78893,78897,78909,82404
/trunk/phase3/HISTORY:79860,80620
/trunk/phase3/RELEASE-NOTES:78893,78897,78909,78990,79166,79324,79454-79456,79536,79727,79733,79746,79749,79773-79774,79844,80109,80113,80163,80222-80223,80322,80324,80326,80328,80339,80350-80351,80355,80358,80362-80363,80371,80442,80475,80492,80495,80540,80554,80575,80608,80620,80656,80666,80679,80685,80694,80728,80765,80813,80815,80841,81121,81124,81177,81186-81187,81197,81209-81211,81215,81238,81246,81262,81264,81430,81488,81496,81548,81554,81561,81589,81600,81611,81620,81622,81640,81648,81650-81652,82000,82022,82155-82156,82191,82193,82200,82203,82218,82297,82312,82337,82404,82408-82409,82453,82456-82458,82460,82465,82473-82474,82478,82482,82486,82513,82518,82530,82572,82608,82696,82810,82813-82815,82818,82836,82853,82858,83061,83067,83114,83270,83284,83374,83390,83392,83402-83403,83410-83411,83420,83461,83463,83583,83586-83587,83610,83716,83764,83787,83798,83813,83817,83866,83876,83979,84118,84228,84459,84729,84820,84985,85140,85152,85194,85377,85555,85583,86100,86121,86130,86142,86146,86183,86210
Modified: branches/wmf/1.17wmf1/includes/DefaultSettings.php
===================================================================
--- branches/wmf/1.17wmf1/includes/DefaultSettings.php 2011-08-29 17:31:47 UTC
(rev 95680)
+++ branches/wmf/1.17wmf1/includes/DefaultSettings.php 2011-08-29 17:56:56 UTC
(rev 95681)
@@ -454,7 +454,19 @@
$wgAllowAsyncCopyUploads = false;
/**
- * Max size for uploads, in bytes. Applies to all uploads.
+ * Max size for uploads, in bytes. If not set to an array, applies to all
+ * uploads. If set to an array, per upload type maximums can be set, using the
+ * file and url keys. If the * key is set this value will be used as maximum
+ * for non-specified types.
+ *
+ * For example:
+ * $wgUploadSize = array(
+ * '*' => 250 * 1024,
+ * 'url' => 500 * 1024,
+ * );
+ * Sets the maximum for all uploads to 250 kB except for upload-by-url, which
+ * will have a maximum of 500 kB.
+ *
*/
$wgMaxUploadSize = 1024*1024*100; # 100MB
Property changes on: branches/wmf/1.17wmf1/includes/DefaultSettings.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes/DefaultSettings.php:51646
/branches/REL1_17/phase3/includes/DefaultSettings.php:81654
/branches/new-installer/phase3/includes/DefaultSettings.php:43664-66004
/branches/sqlite/includes/DefaultSettings.php:58211-58321
/branches/wmf/1.16wmf4/includes/DefaultSettings.php:67177,69199,76243,77266
/branches/wmf-deployment/includes/DefaultSettings.php:53381,60970
/trunk/phase3/includes/DefaultSettings.php:78395,78990,79166,79324,79746,79844,79860,79968,80109,80113,80137-80138,80205,80210,80222-80223,80231,80272,80381,80432-80433,80436,80443,80475,80554,80575,80590,80614-80616,80620,80656,80666,80813,80815,80837,80841,81311,81313,81349,81352,81376,81389,81397,81399,81412,81430,81488,81496,81548,81554,81561,81589,81600,81611-81612,81615,81620,81622,81640,81648,81650-81652,81657,81674,81689,81692,82022,82193,82468,82696,82836,82853,82858,83061,83067,83114,83135-83136,83140,83143,83147,83208,83270,83284,83374,83390,83392,83402-83403,83410-83411,83416,83420,83461,83463,83492,83512,83583,83610,83617,83716,83764,83787,83798,83813-83814,83866,83885,83891,83897,83902-83903,83988-83989,83997-83998,84392,84459,84729,84820,84985,85128,85140,85152,85194,85377,85555,85583,86100,86121,86130,86142,86146,86183,86210,92036,92044,93476,93778,93820-93822,93847,94536,94539-94540,94592,94594,94670,94990,94995-94996,95000-95002,95007,95010-95011,95016-95017
+ /branches/REL1_15/phase3/includes/DefaultSettings.php:51646
/branches/REL1_17/phase3/includes/DefaultSettings.php:81654
/branches/new-installer/phase3/includes/DefaultSettings.php:43664-66004
/branches/sqlite/includes/DefaultSettings.php:58211-58321
/branches/wmf/1.16wmf4/includes/DefaultSettings.php:67177,69199,76243,77266
/branches/wmf-deployment/includes/DefaultSettings.php:53381,60970
/trunk/phase3/includes/DefaultSettings.php:78395,78990,79166,79324,79746,79749,79844,79860,79968,80109,80113,80137-80138,80205,80210,80222-80223,80231,80272,80381,80432-80433,80436,80443,80475,80554,80575,80590,80614-80616,80620,80656,80666,80813,80815,80837,80841,81311,81313,81349,81352,81376,81389,81397,81399,81412,81430,81488,81496,81548,81554,81561,81589,81600,81611-81612,81615,81620,81622,81640,81648,81650-81652,81657,81674,81689,81692,82022,82193,82468,82696,82836,82853,82858,83061,83067,83114,83135-83136,83140,83143,83147,83208,83270,83284,83374,83390,83392,83402-83403,83410-83411,83416,83420,83461,83463,83492,83512,83583,83610,83617,83716,83764,83787,83798,83813-83814,83866,83885,83891,83897,83902-83903,83988-83989,83997-83998,84392,84459,84729,84820,84985,85128,85140,85152,85194,85377,85555,85583,86100,86121,86130,86142,86146,86183,86210,92036,92044,93476,93778,93820-93822,93847,94536,94539-94540,94592,94594,94670,94990,94995-94996,95000-95002,95007,95010-95011,95016-95017
Modified: branches/wmf/1.17wmf1/includes/specials/SpecialUpload.php
===================================================================
--- branches/wmf/1.17wmf1/includes/specials/SpecialUpload.php 2011-08-29
17:31:47 UTC (rev 95680)
+++ branches/wmf/1.17wmf1/includes/specials/SpecialUpload.php 2011-08-29
17:56:56 UTC (rev 95681)
@@ -812,7 +812,6 @@
*/
protected function getSourceSection() {
global $wgLang, $wgUser, $wgRequest;
- global $wgMaxUploadSize;
if ( $this->mSessionKey ) {
return array(
@@ -855,7 +854,7 @@
wfShorthandToInteger( min(
wfShorthandToInteger(
ini_get(
'upload_max_filesize' )
- ), $wgMaxUploadSize
+ ),
UploadBase::getMaxUploadSize( 'file' )
) )
)
) . ' ' . wfMsgHtml( 'upload_source_file' ),
@@ -871,7 +870,7 @@
'radio' => &$radio,
'help' => wfMsgExt( 'upload-maxfilesize',
array( 'parseinline',
'escapenoentities' ),
- $wgLang->formatSize(
$wgMaxUploadSize )
+ $wgLang->formatSize(
UploadBase::getMaxUploadSize( 'url' ) )
) . ' ' . wfMsgHtml(
'upload_source_url' ),
'checked' => $selectedSourceType == 'url',
);
Property changes on: branches/wmf/1.17wmf1/includes/specials/SpecialUpload.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes/specials/SpecialUpload.php:51646
/branches/sqlite/includes/specials/SpecialUpload.php:58211-58321
/branches/wmf/1.16wmf4/includes/specials/SpecialUpload.php:67177,69199,76243,77266
/branches/wmf-deployment/includes/specials/SpecialUpload.php:53381,56967,60970
/trunk/phase3/includes/specials/SpecialUpload.php:78426,78560,79758,83586-83587,83817,83876,83979,84118,84228,84579,84731,84761-84762
+ /branches/REL1_15/phase3/includes/specials/SpecialUpload.php:51646
/branches/sqlite/includes/specials/SpecialUpload.php:58211-58321
/branches/wmf/1.16wmf4/includes/specials/SpecialUpload.php:67177,69199,76243,77266
/branches/wmf-deployment/includes/specials/SpecialUpload.php:53381,56967,60970
/trunk/phase3/includes/specials/SpecialUpload.php:78426,78560,79749,79758,83586-83587,83817,83876,83979,84118,84228,84579,84731,84761-84762
Modified: branches/wmf/1.17wmf1/includes/upload/UploadBase.php
===================================================================
--- branches/wmf/1.17wmf1/includes/upload/UploadBase.php 2011-08-29
17:31:47 UTC (rev 95680)
+++ branches/wmf/1.17wmf1/includes/upload/UploadBase.php 2011-08-29
17:56:56 UTC (rev 95681)
@@ -135,6 +135,14 @@
}
public function __construct() {}
+
+ /**
+ * Returns the upload type. Should be overridden by child classes
+ *
+ * @since 1.18
+ * @return string
+ */
+ public function getSourceType() { return null; }
/**
* Initialize the path information
@@ -219,11 +227,11 @@
/**
* Honor $wgMaxUploadSize
*/
- global $wgMaxUploadSize;
- if( $this->mFileSize > $wgMaxUploadSize ) {
+ $maxSize = self::getMaxUploadSize( $this->getSourceType() );
+ if( $this->mFileSize > $maxSize ) {
return array(
'status' => self::FILE_TOO_LARGE,
- 'max' => $wgMaxUploadSize,
+ 'max' => $maxSize,
);
}
@@ -1230,4 +1238,19 @@
unset( $code['status'] );
return Status::newFatal( $this->getVerificationErrorCode( $code
), $error );
}
+
+ public static function getMaxUploadSize( $forType = null ) {
+ global $wgMaxUploadSize;
+
+ if ( is_array( $wgMaxUploadSize ) ) {
+ if ( !is_null( $forType) && isset(
$wgMaxUploadSize[$forType] ) ) {
+ return $wgMaxUploadSize[$forType];
+ } else {
+ return $wgMaxUploadSize['*'];
+ }
+ } else {
+ return intval( $wgMaxUploadSize );
+ }
+
+ }
}
Property changes on: branches/wmf/1.17wmf1/includes/upload/UploadBase.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes/upload/UploadBase.php:51646
/branches/new-installer/phase3/includes/upload/UploadBase.php:43664-66004
/branches/sqlite/includes/upload/UploadBase.php:58211-58321
/branches/uploadwizard/phase3/includes/upload/UploadBase.php:73550-75905
/branches/wmf/1.16wmf4/includes/upload/UploadBase.php:67177,69199,76243,77266
/branches/wmf-deployment/includes/upload/UploadBase.php:53381,60970
/trunk/phase3/includes/upload/UploadBase.php:78078,78285,78426,79246,79358,79480,79655,79693,79706,79710,80576,80583,80656,80842,80900,80913,80918-80920,80973-80974,80979,80993,83586-83587,83817,83876,83979,84118,84228,84573,84731,84761-84762,91022,91679,92009,92030,92035,92039,92043,92081,92200,92213,92247,92250,92269,92459,92815,93065,93137,93476,93778,94536,94539-94540,94592,94594,94670
+ /branches/REL1_15/phase3/includes/upload/UploadBase.php:51646
/branches/new-installer/phase3/includes/upload/UploadBase.php:43664-66004
/branches/sqlite/includes/upload/UploadBase.php:58211-58321
/branches/uploadwizard/phase3/includes/upload/UploadBase.php:73550-75905
/branches/wmf/1.16wmf4/includes/upload/UploadBase.php:67177,69199,76243,77266
/branches/wmf-deployment/includes/upload/UploadBase.php:53381,60970
/trunk/phase3/includes/upload/UploadBase.php:78078,78285,78426,79246,79358,79480,79655,79693,79706,79710,79749,80576,80583,80656,80842,80900,80913,80918-80920,80973-80974,80979,80993,83586-83587,83817,83876,83979,84118,84228,84573,84731,84761-84762,91022,91679,92009,92030,92035,92039,92043,92081,92200,92213,92247,92250,92269,92459,92815,93065,93137,93476,93778,94536,94539-94540,94592,94594,94670
Modified: branches/wmf/1.17wmf1/includes/upload/UploadFromFile.php
===================================================================
--- branches/wmf/1.17wmf1/includes/upload/UploadFromFile.php 2011-08-29
17:31:47 UTC (rev 95680)
+++ branches/wmf/1.17wmf1/includes/upload/UploadFromFile.php 2011-08-29
17:56:56 UTC (rev 95681)
@@ -45,11 +45,10 @@
# proper error can be shown to the user
if ( is_null( $this->mTempPath ) || $this->isEmptyFile() ) {
if ( $this->mUpload->isIniSizeOverflow() ) {
- global $wgMaxUploadSize;
return array(
'status' => self::FILE_TOO_LARGE,
'max' => min(
- $wgMaxUploadSize,
+ self::getMaxUploadSize(
$this->getSourceType() ),
wfShorthandToInteger( ini_get(
'upload_max_filesize' ) ),
wfShorthandToInteger( ini_get(
'post_max_size' ) )
),
Property changes on: branches/wmf/1.17wmf1/includes/upload/UploadFromFile.php
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/REL1_15/phase3/includes/upload/UploadFromFile.php:51646
/branches/new-installer/phase3/includes/upload/UploadFromFile.php:43664-66004
/branches/sqlite/includes/upload/UploadFromFile.php:58211-58321
/branches/uploadwizard/phase3/includes/upload/UploadFromFile.php:73550-75905
/branches/wmf/1.16wmf4/includes/upload/UploadFromFile.php:67177,69199,76243,77266
/branches/wmf-deployment/includes/upload/UploadFromFile.php:53381,60970
/trunk/phase3/includes/upload/UploadFromFile.php:90217,93476,93778,94536,94539-94540,94592,94594,94670
+ /branches/REL1_15/phase3/includes/upload/UploadFromFile.php:51646
/branches/new-installer/phase3/includes/upload/UploadFromFile.php:43664-66004
/branches/sqlite/includes/upload/UploadFromFile.php:58211-58321
/branches/uploadwizard/phase3/includes/upload/UploadFromFile.php:73550-75905
/branches/wmf/1.16wmf4/includes/upload/UploadFromFile.php:67177,69199,76243,77266
/branches/wmf-deployment/includes/upload/UploadFromFile.php:53381,60970
/trunk/phase3/includes/upload/UploadFromFile.php:79749,90217,93476,93778,94536,94539-94540,94592,94594,94670
Modified: branches/wmf/1.17wmf1/includes/upload/UploadFromStash.php
===================================================================
--- branches/wmf/1.17wmf1/includes/upload/UploadFromStash.php 2011-08-29
17:31:47 UTC (rev 95680)
+++ branches/wmf/1.17wmf1/includes/upload/UploadFromStash.php 2011-08-29
17:56:56 UTC (rev 95681)
@@ -70,6 +70,8 @@
$this->mVirtualTempPath = $metadata['us_path'];
$this->mFileProps = $this->stash->getFileProps( $key );
$this->mSourceType = $metadata['us_source_type'];
+ $this->mSourceType = isset( $sessionData['mSourceType']
) ?
+ $sessionData['mSourceType'] : null;
}
public function initializeFromRequest( &$request ) {
@@ -82,6 +84,10 @@
return $this->initialize( $fileKey, $desiredDestName );
}
+ public function getSourceType() {
+ return $this->mSourceType;
+ }
+
/**
* File has been previously verified so no need to do so again.
*/
Modified: branches/wmf/1.17wmf1/includes/upload/UploadFromUrl.php
===================================================================
--- branches/wmf/1.17wmf1/includes/upload/UploadFromUrl.php 2011-08-29
17:31:47 UTC (rev 95680)
+++ branches/wmf/1.17wmf1/includes/upload/UploadFromUrl.php 2011-08-29
17:56:56 UTC (rev 95681)
@@ -81,6 +81,7 @@
&& $wgUser->isAllowed( 'upload_by_url' );
}
+ public function getSourceType() { return 'url'; }
public function fetchFile() {
if ( !Http::isValidURI( $this->mUrl ) ) {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs