r82507 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82506‎ | r82507 | r82508 >
Date:13:33, 20 February 2011
Author:reedy
Status:ok
Tags:
Comment:
More explicit variable definitions, function documentation
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialUpload.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadBase.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadFromFile.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadFromStash.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadFromUrl.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadStash.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/upload/UploadFromStash.php
@@ -8,6 +8,10 @@
99 */
1010
1111 class UploadFromStash extends UploadBase {
 12+
 13+ protected $initializePathInfo, $mSessionKey, $mVirtualTempPath,
 14+ $mFileProps, $mSourceType;
 15+
1216 public static function isValidSessionKey( $key, $sessionData ) {
1317 return !empty( $key ) &&
1418 is_array( $sessionData ) &&
@@ -16,6 +20,11 @@
1721 $sessionData[$key]['version'] == UploadBase::SESSION_VERSION;
1822 }
1923
 24+ /**
 25+ * @param $request WebRequest
 26+ *
 27+ * @return Boolean
 28+ */
2029 public static function isValidRequest( $request ) {
2130 $sessionData = $request->getSessionData( UploadBase::SESSION_KEYNAME );
2231 return self::isValidSessionKey(
@@ -45,6 +54,9 @@
4655 $sessionData['mSourceType'] : null;
4756 }
4857
 58+ /**
 59+ * @param $request WebRequest
 60+ */
4961 public function initializeFromRequest( &$request ) {
5062 $sessionKey = $request->getText( 'wpSessionKey' );
5163 $sessionData = $request->getSessionData( UploadBase::SESSION_KEYNAME );
@@ -66,7 +78,6 @@
6779 return true;
6880 }
6981
70 -
7182 /**
7283 * There is no need to stash the image twice
7384 */
Index: trunk/phase3/includes/upload/UploadFromUrl.php
@@ -12,9 +12,13 @@
1313 protected $mAsync, $mUrl;
1414 protected $mIgnoreWarnings = true;
1515
 16+ protected $mTempPath;
 17+
1618 /**
1719 * Checks if the user is allowed to use the upload-by-URL feature. If the
1820 * user is allowed, pass on permissions checking to the parent.
 21+ *
 22+ * @param $user User
1923 */
2024 public static function isAllowed( $user ) {
2125 if ( !$user->isAllowed( 'upload_by_url' ) )
@@ -56,7 +60,7 @@
5761
5862 /**
5963 * Entry point for SpecialUpload
60 - * @param $request Object: WebRequest object
 64+ * @param $request WebRequest object
6165 */
6266 public function initializeFromRequest( &$request ) {
6367 $desiredDestName = $request->getText( 'wpDestFile' );
@@ -70,7 +74,7 @@
7175 }
7276
7377 /**
74 - * @param $request Object: WebRequest object
 78+ * @param $request WebRequest object
7579 */
7680 public static function isValidRequest( $request ) {
7781 global $wgUser;
@@ -215,5 +219,4 @@
216220 return $sessionKey;
217221 }
218222
219 -
220223 }
Index: trunk/phase3/includes/upload/UploadBase.php
@@ -18,7 +18,8 @@
1919 protected $mDesiredDestName, $mDestName, $mRemoveTempFile, $mSourceType;
2020 protected $mTitle = false, $mTitleError = 0;
2121 protected $mFilteredName, $mFinalExtension;
22 - protected $mLocalFile;
 22+ protected $mLocalFile, $mFileSize, $mFileProps;
 23+ protected $mBlackListedExtensions;
2324
2425 const SUCCESS = 0;
2526 const OK = 0;
@@ -81,6 +82,8 @@
8283 * Returns true if the user can use this upload module or else a string
8384 * identifying the missing permission.
8485 * Can be overriden by subclasses.
 86+ *
 87+ * @param $user User
8588 */
8689 public static function isAllowed( $user ) {
8790 foreach ( array( 'upload', 'edit' ) as $permission ) {
@@ -96,6 +99,8 @@
97100
98101 /**
99102 * Create a form of UploadBase depending on wpSourceType and initializes it
 103+ *
 104+ * @param $request WebRequest
100105 */
101106 public static function createFromRequest( &$request, $type = null ) {
102107 $type = $type ? $type : $request->getVal( 'wpSourceType', 'File' );
@@ -399,7 +404,7 @@
400405 * isAllowed() should be called as well for generic is-user-blocked or
401406 * can-user-upload checking.
402407 *
403 - * @param $user the User object to verify the permissions against
 408+ * @param $user User object to verify the permissions against
404409 * @return mixed An array as returned by getUserPermissionsErrors or true
405410 * in case the user has proper permissions.
406411 */
@@ -504,6 +509,8 @@
505510 * Really perform the upload. Stores the file in the local repo, watches
506511 * if necessary and runs the UploadComplete hook.
507512 *
 513+ * @param $user User
 514+ *
508515 * @return Status indicating the whether the upload succeeded.
509516 */
510517 public function performUpload( $comment, $pageText, $watch, $user ) {
@@ -618,6 +625,8 @@
619626
620627 /**
621628 * Return the local file and initializes if necessary.
 629+ *
 630+ * @return LocalFile
622631 */
623632 public function getLocalFile() {
624633 if( is_null( $this->mLocalFile ) ) {
@@ -1049,6 +1058,8 @@
10501059 * Check if there's an overwrite conflict and, if so, if restrictions
10511060 * forbid this user from performing the upload.
10521061 *
 1062+ * @param $user User
 1063+ *
10531064 * @return mixed true on success, error string on failure
10541065 */
10551066 private function checkOverwrite( $user ) {
Index: trunk/phase3/includes/upload/UploadStash.php
@@ -21,7 +21,7 @@
2222 public $repo;
2323
2424 // array of initialized objects obtained from session (lazily initialized upon getFile())
25 - private $files = array();
 25+ private $files = array();
2626
2727 // TODO: Once UploadBase starts using this, switch to use these constants rather than UploadBase::SESSION*
2828 // const SESSION_VERSION = 2;
@@ -46,7 +46,6 @@
4747
4848 }
4949
50 -
5150 /**
5251 * Get a file and its metadata from the stash.
5352 * May throw exception if session data cannot be parsed due to schema change, or key not found.
@@ -126,7 +125,6 @@
127126 throw new UploadStashBadPathException( "key '$key' is not in a proper format" );
128127 }
129128
130 -
131129 // if not already in a temporary area, put it there
132130 $status = $this->repo->storeTemp( basename( $path ), $path );
133131
@@ -230,6 +228,7 @@
231229 private $sessionKey;
232230 private $sessionData;
233231 private $urlName;
 232+ protected $url;
234233
235234 /**
236235 * 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 @@
99 */
1010
1111 class UploadFromFile extends UploadBase {
 12+
 13+ /**
 14+ * @var WebRequestUpload
 15+ */
1216 protected $mUpload = null;
1317
 18+ /**
 19+ * @param $request WebRequest
 20+ */
1421 function initializeFromRequest( &$request ) {
1522 $upload = $request->getUpload( 'wpUploadFile' );
1623 $desiredDestName = $request->getText( 'wpDestFile' );
@@ -61,6 +68,4 @@
6269 public function getFileTempname() {
6370 return $this->mUpload->getTempname();
6471 }
65 -
66 -
6772 }
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -473,7 +473,7 @@
474474 * The intention is that this function replaces all old wfMsg* functions.
475475 * @param $key \string Message key.
476476 * Varargs: normal message parameters.
477 - * @return \type{Message}
 477+ * @return Message
478478 * @since 1.17
479479 */
480480 function wfMessage( $key /*...*/) {
Index: trunk/phase3/includes/specials/SpecialUpload.php
@@ -440,7 +440,6 @@
441441 return;
442442 }
443443
444 -
445444 // Upload verification
446445 $details = $this->mUpload->verifyUpload();
447446 if ( $details['status'] != UploadBase::OK ) {

Status & tagging log