Index: trunk/phase3/includes/upload/UploadFromStash.php |
— | — | @@ -8,6 +8,10 @@ |
9 | 9 | */ |
10 | 10 | |
11 | 11 | class UploadFromStash extends UploadBase { |
| 12 | + |
| 13 | + protected $initializePathInfo, $mSessionKey, $mVirtualTempPath, |
| 14 | + $mFileProps, $mSourceType; |
| 15 | + |
12 | 16 | public static function isValidSessionKey( $key, $sessionData ) { |
13 | 17 | return !empty( $key ) && |
14 | 18 | is_array( $sessionData ) && |
— | — | @@ -16,6 +20,11 @@ |
17 | 21 | $sessionData[$key]['version'] == UploadBase::SESSION_VERSION; |
18 | 22 | } |
19 | 23 | |
| 24 | + /** |
| 25 | + * @param $request WebRequest |
| 26 | + * |
| 27 | + * @return Boolean |
| 28 | + */ |
20 | 29 | public static function isValidRequest( $request ) { |
21 | 30 | $sessionData = $request->getSessionData( UploadBase::SESSION_KEYNAME ); |
22 | 31 | return self::isValidSessionKey( |
— | — | @@ -45,6 +54,9 @@ |
46 | 55 | $sessionData['mSourceType'] : null; |
47 | 56 | } |
48 | 57 | |
| 58 | + /** |
| 59 | + * @param $request WebRequest |
| 60 | + */ |
49 | 61 | public function initializeFromRequest( &$request ) { |
50 | 62 | $sessionKey = $request->getText( 'wpSessionKey' ); |
51 | 63 | $sessionData = $request->getSessionData( UploadBase::SESSION_KEYNAME ); |
— | — | @@ -66,7 +78,6 @@ |
67 | 79 | return true; |
68 | 80 | } |
69 | 81 | |
70 | | - |
71 | 82 | /** |
72 | 83 | * There is no need to stash the image twice |
73 | 84 | */ |
Index: trunk/phase3/includes/upload/UploadFromUrl.php |
— | — | @@ -12,9 +12,13 @@ |
13 | 13 | protected $mAsync, $mUrl; |
14 | 14 | protected $mIgnoreWarnings = true; |
15 | 15 | |
| 16 | + protected $mTempPath; |
| 17 | + |
16 | 18 | /** |
17 | 19 | * Checks if the user is allowed to use the upload-by-URL feature. If the |
18 | 20 | * user is allowed, pass on permissions checking to the parent. |
| 21 | + * |
| 22 | + * @param $user User |
19 | 23 | */ |
20 | 24 | public static function isAllowed( $user ) { |
21 | 25 | if ( !$user->isAllowed( 'upload_by_url' ) ) |
— | — | @@ -56,7 +60,7 @@ |
57 | 61 | |
58 | 62 | /** |
59 | 63 | * Entry point for SpecialUpload |
60 | | - * @param $request Object: WebRequest object |
| 64 | + * @param $request WebRequest object |
61 | 65 | */ |
62 | 66 | public function initializeFromRequest( &$request ) { |
63 | 67 | $desiredDestName = $request->getText( 'wpDestFile' ); |
— | — | @@ -70,7 +74,7 @@ |
71 | 75 | } |
72 | 76 | |
73 | 77 | /** |
74 | | - * @param $request Object: WebRequest object |
| 78 | + * @param $request WebRequest object |
75 | 79 | */ |
76 | 80 | public static function isValidRequest( $request ) { |
77 | 81 | global $wgUser; |
— | — | @@ -215,5 +219,4 @@ |
216 | 220 | return $sessionKey; |
217 | 221 | } |
218 | 222 | |
219 | | - |
220 | 223 | } |
Index: trunk/phase3/includes/upload/UploadBase.php |
— | — | @@ -18,7 +18,8 @@ |
19 | 19 | protected $mDesiredDestName, $mDestName, $mRemoveTempFile, $mSourceType; |
20 | 20 | protected $mTitle = false, $mTitleError = 0; |
21 | 21 | protected $mFilteredName, $mFinalExtension; |
22 | | - protected $mLocalFile; |
| 22 | + protected $mLocalFile, $mFileSize, $mFileProps; |
| 23 | + protected $mBlackListedExtensions; |
23 | 24 | |
24 | 25 | const SUCCESS = 0; |
25 | 26 | const OK = 0; |
— | — | @@ -81,6 +82,8 @@ |
82 | 83 | * Returns true if the user can use this upload module or else a string |
83 | 84 | * identifying the missing permission. |
84 | 85 | * Can be overriden by subclasses. |
| 86 | + * |
| 87 | + * @param $user User |
85 | 88 | */ |
86 | 89 | public static function isAllowed( $user ) { |
87 | 90 | foreach ( array( 'upload', 'edit' ) as $permission ) { |
— | — | @@ -96,6 +99,8 @@ |
97 | 100 | |
98 | 101 | /** |
99 | 102 | * Create a form of UploadBase depending on wpSourceType and initializes it |
| 103 | + * |
| 104 | + * @param $request WebRequest |
100 | 105 | */ |
101 | 106 | public static function createFromRequest( &$request, $type = null ) { |
102 | 107 | $type = $type ? $type : $request->getVal( 'wpSourceType', 'File' ); |
— | — | @@ -399,7 +404,7 @@ |
400 | 405 | * isAllowed() should be called as well for generic is-user-blocked or |
401 | 406 | * can-user-upload checking. |
402 | 407 | * |
403 | | - * @param $user the User object to verify the permissions against |
| 408 | + * @param $user User object to verify the permissions against |
404 | 409 | * @return mixed An array as returned by getUserPermissionsErrors or true |
405 | 410 | * in case the user has proper permissions. |
406 | 411 | */ |
— | — | @@ -504,6 +509,8 @@ |
505 | 510 | * Really perform the upload. Stores the file in the local repo, watches |
506 | 511 | * if necessary and runs the UploadComplete hook. |
507 | 512 | * |
| 513 | + * @param $user User |
| 514 | + * |
508 | 515 | * @return Status indicating the whether the upload succeeded. |
509 | 516 | */ |
510 | 517 | public function performUpload( $comment, $pageText, $watch, $user ) { |
— | — | @@ -618,6 +625,8 @@ |
619 | 626 | |
620 | 627 | /** |
621 | 628 | * Return the local file and initializes if necessary. |
| 629 | + * |
| 630 | + * @return LocalFile |
622 | 631 | */ |
623 | 632 | public function getLocalFile() { |
624 | 633 | if( is_null( $this->mLocalFile ) ) { |
— | — | @@ -1049,6 +1058,8 @@ |
1050 | 1059 | * Check if there's an overwrite conflict and, if so, if restrictions |
1051 | 1060 | * forbid this user from performing the upload. |
1052 | 1061 | * |
| 1062 | + * @param $user User |
| 1063 | + * |
1053 | 1064 | * @return mixed true on success, error string on failure |
1054 | 1065 | */ |
1055 | 1066 | private function checkOverwrite( $user ) { |
Index: trunk/phase3/includes/upload/UploadStash.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | public $repo; |
23 | 23 | |
24 | 24 | // array of initialized objects obtained from session (lazily initialized upon getFile()) |
25 | | - private $files = array(); |
| 25 | + private $files = array(); |
26 | 26 | |
27 | 27 | // TODO: Once UploadBase starts using this, switch to use these constants rather than UploadBase::SESSION* |
28 | 28 | // const SESSION_VERSION = 2; |
— | — | @@ -46,7 +46,6 @@ |
47 | 47 | |
48 | 48 | } |
49 | 49 | |
50 | | - |
51 | 50 | /** |
52 | 51 | * Get a file and its metadata from the stash. |
53 | 52 | * May throw exception if session data cannot be parsed due to schema change, or key not found. |
— | — | @@ -126,7 +125,6 @@ |
127 | 126 | throw new UploadStashBadPathException( "key '$key' is not in a proper format" ); |
128 | 127 | } |
129 | 128 | |
130 | | - |
131 | 129 | // if not already in a temporary area, put it there |
132 | 130 | $status = $this->repo->storeTemp( basename( $path ), $path ); |
133 | 131 | |
— | — | @@ -230,6 +228,7 @@ |
231 | 229 | private $sessionKey; |
232 | 230 | private $sessionData; |
233 | 231 | private $urlName; |
| 232 | + protected $url; |
234 | 233 | |
235 | 234 | /** |
236 | 235 | * A LocalFile wrapper around a file that has been temporarily stashed, so we can do things like create thumbnails for it |
Index: trunk/phase3/includes/upload/UploadFromFile.php |
— | — | @@ -8,8 +8,15 @@ |
9 | 9 | */ |
10 | 10 | |
11 | 11 | class UploadFromFile extends UploadBase { |
| 12 | + |
| 13 | + /** |
| 14 | + * @var WebRequestUpload |
| 15 | + */ |
12 | 16 | protected $mUpload = null; |
13 | 17 | |
| 18 | + /** |
| 19 | + * @param $request WebRequest |
| 20 | + */ |
14 | 21 | function initializeFromRequest( &$request ) { |
15 | 22 | $upload = $request->getUpload( 'wpUploadFile' ); |
16 | 23 | $desiredDestName = $request->getText( 'wpDestFile' ); |
— | — | @@ -61,6 +68,4 @@ |
62 | 69 | public function getFileTempname() { |
63 | 70 | return $this->mUpload->getTempname(); |
64 | 71 | } |
65 | | - |
66 | | - |
67 | 72 | } |
Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -473,7 +473,7 @@ |
474 | 474 | * The intention is that this function replaces all old wfMsg* functions. |
475 | 475 | * @param $key \string Message key. |
476 | 476 | * Varargs: normal message parameters. |
477 | | - * @return \type{Message} |
| 477 | + * @return Message |
478 | 478 | * @since 1.17 |
479 | 479 | */ |
480 | 480 | function wfMessage( $key /*...*/) { |
Index: trunk/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -440,7 +440,6 @@ |
441 | 441 | return; |
442 | 442 | } |
443 | 443 | |
444 | | - |
445 | 444 | // Upload verification |
446 | 445 | $details = $this->mUpload->verifyUpload(); |
447 | 446 | if ( $details['status'] != UploadBase::OK ) { |