Cleaning up little things, updates to code clarity, documentation fixes per Catrope...
authorIan Baker <raindrift@users.mediawiki.org>
Tue, 16 Aug 2011 17:57:32 +0000 (17:57 +0000)
committerIan Baker <raindrift@users.mediawiki.org>
Tue, 16 Aug 2011 17:57:32 +0000 (17:57 +0000)
followup to r94536, r94592, r94594

includes/upload/UploadBase.php
includes/upload/UploadFromStash.php
includes/upload/UploadStash.php

index 429a363..443b7c9 100644 (file)
@@ -742,7 +742,6 @@ abstract class UploadBase {
         * This method returns the file object, which also has a 'fileKey' property which can be passed through a form or
         * API request to find this stashed file again.
         *
-        * @param $key String: (optional) the file key used to find the file info again. If not supplied, a key will be autogenerated.
         * @return UploadStashFile stashed file
         */
        public function stashFile() {
@@ -757,7 +756,6 @@ abstract class UploadBase {
        /**
         * Stash a file in a temporary directory, returning a key which can be used to find the file again. See stashFile().
         *
-        * @param $key String: (optional) the file key used to find the file info again. If not supplied, a key will be autogenerated.
         * @return String: file key
         */
        public function stashFileGetKey() {
@@ -767,7 +765,6 @@ abstract class UploadBase {
        /** 
         * alias for stashFileGetKey, for backwards compatibility
         *
-        * @param $key String: (optional) the file key used to find the file info again. If not supplied, a key will be autogenerated.
         * @return String: file key
         */
        public function stashSession() {
index a2f9be5..22a92f3 100644 (file)
@@ -38,7 +38,7 @@ class UploadFromStash extends UploadBase {
        
        public static function isValidKey( $key ) {
                // this is checked in more detail in UploadStash
-               return preg_match( UploadStash::KEY_FORMAT_REGEX, $key ) ? true : false;
+               return (bool)preg_match( UploadStash::KEY_FORMAT_REGEX, $key );
        }
 
        /**
index cad8585..9bdcc1b 100644 (file)
@@ -96,7 +96,7 @@ class UploadStash {
                if ( !isset( $this->fileMetadata[$key] ) ) {
                        if ( !$this->fetchFileMetadata( $key ) ) {
                                // If nothing was received, it's likely due to replication lag.  Check the master to see if the record is there.
-                               $this->fetchFileMetadata( $key, true );
+                               $this->fetchFileMetadata( $key, DB_MASTER );
                        }
 
                        if ( !isset( $this->fileMetadata[$key] ) ) {
@@ -155,7 +155,6 @@ class UploadStash {
         *
         * @param $path String: path to file you want stashed
         * @param $sourceType String: the type of upload that generated this file (currently, I believe, 'file' or null)
-        * @param $key String: optional, unique key for this file. Used for directory hashing when storing, otherwise not important
         * @throws UploadStashBadPathException
         * @throws UploadStashFileException
         * @throws UploadStashNotLoggedInException
@@ -248,7 +247,6 @@ class UploadStash {
                        'us_status' => 'finished'
                );
 
-               // if a row exists but previous checks on it passed, let the current user take over this key.
                $dbw->insert(
                        'uploadstash',
                        $this->fileMetadata[$key],
@@ -424,10 +422,10 @@ class UploadStash {
         * @param $key String: key
         * @return boolean
         */
-       protected function fetchFileMetadata( $key, $readFromMaster = false ) {
+       protected function fetchFileMetadata( $key, $readFromDB = DB_SLAVE ) {
                // populate $fileMetadata[$key]
                $dbr = null;
-               if( $readFromMaster ) {
+               if( $readFromDB === DB_MASTER ) {
                        // sometimes reading from the master is necessary, if there's replication lag.
                        $dbr = $this->repo->getMasterDb();
                } else {