Index: trunk/phase3/includes/upload/UploadFromStash.php |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | |
40 | 40 | public static function isValidKey( $key ) { |
41 | 41 | // this is checked in more detail in UploadStash |
42 | | - return preg_match( UploadStash::KEY_FORMAT_REGEX, $key ) ? true : false; |
| 42 | + return (bool)preg_match( UploadStash::KEY_FORMAT_REGEX, $key ); |
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
Index: trunk/phase3/includes/upload/UploadBase.php |
— | — | @@ -742,7 +742,6 @@ |
743 | 743 | * This method returns the file object, which also has a 'fileKey' property which can be passed through a form or |
744 | 744 | * API request to find this stashed file again. |
745 | 745 | * |
746 | | - * @param $key String: (optional) the file key used to find the file info again. If not supplied, a key will be autogenerated. |
747 | 746 | * @return UploadStashFile stashed file |
748 | 747 | */ |
749 | 748 | public function stashFile() { |
— | — | @@ -757,7 +756,6 @@ |
758 | 757 | /** |
759 | 758 | * Stash a file in a temporary directory, returning a key which can be used to find the file again. See stashFile(). |
760 | 759 | * |
761 | | - * @param $key String: (optional) the file key used to find the file info again. If not supplied, a key will be autogenerated. |
762 | 760 | * @return String: file key |
763 | 761 | */ |
764 | 762 | public function stashFileGetKey() { |
— | — | @@ -767,7 +765,6 @@ |
768 | 766 | /** |
769 | 767 | * alias for stashFileGetKey, for backwards compatibility |
770 | 768 | * |
771 | | - * @param $key String: (optional) the file key used to find the file info again. If not supplied, a key will be autogenerated. |
772 | 769 | * @return String: file key |
773 | 770 | */ |
774 | 771 | public function stashSession() { |
Index: trunk/phase3/includes/upload/UploadStash.php |
— | — | @@ -96,7 +96,7 @@ |
97 | 97 | if ( !isset( $this->fileMetadata[$key] ) ) { |
98 | 98 | if ( !$this->fetchFileMetadata( $key ) ) { |
99 | 99 | // If nothing was received, it's likely due to replication lag. Check the master to see if the record is there. |
100 | | - $this->fetchFileMetadata( $key, true ); |
| 100 | + $this->fetchFileMetadata( $key, DB_MASTER ); |
101 | 101 | } |
102 | 102 | |
103 | 103 | if ( !isset( $this->fileMetadata[$key] ) ) { |
— | — | @@ -155,7 +155,6 @@ |
156 | 156 | * |
157 | 157 | * @param $path String: path to file you want stashed |
158 | 158 | * @param $sourceType String: the type of upload that generated this file (currently, I believe, 'file' or null) |
159 | | - * @param $key String: optional, unique key for this file. Used for directory hashing when storing, otherwise not important |
160 | 159 | * @throws UploadStashBadPathException |
161 | 160 | * @throws UploadStashFileException |
162 | 161 | * @throws UploadStashNotLoggedInException |
— | — | @@ -248,7 +247,6 @@ |
249 | 248 | 'us_status' => 'finished' |
250 | 249 | ); |
251 | 250 | |
252 | | - // if a row exists but previous checks on it passed, let the current user take over this key. |
253 | 251 | $dbw->insert( |
254 | 252 | 'uploadstash', |
255 | 253 | $this->fileMetadata[$key], |
— | — | @@ -424,10 +422,10 @@ |
425 | 423 | * @param $key String: key |
426 | 424 | * @return boolean |
427 | 425 | */ |
428 | | - protected function fetchFileMetadata( $key, $readFromMaster = false ) { |
| 426 | + protected function fetchFileMetadata( $key, $readFromDB = DB_SLAVE ) { |
429 | 427 | // populate $fileMetadata[$key] |
430 | 428 | $dbr = null; |
431 | | - if( $readFromMaster ) { |
| 429 | + if( $readFromDB === DB_MASTER ) { |
432 | 430 | // sometimes reading from the master is necessary, if there's replication lag. |
433 | 431 | $dbr = $this->repo->getMasterDb(); |
434 | 432 | } else { |