r94670 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94669‎ | r94670 | r94671 >
Date:17:57, 16 August 2011
Author:raindrift
Status:ok
Tags:
Comment:
Cleaning up little things, updates to code clarity, documentation fixes per Catrope's suggestions.
followup to r94536, r94592, r94594
Modified paths:
  • /trunk/phase3/includes/upload/UploadBase.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadFromStash.php (modified) (history)
  • /trunk/phase3/includes/upload/UploadStash.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/upload/UploadFromStash.php
@@ -38,7 +38,7 @@
3939
4040 public static function isValidKey( $key ) {
4141 // 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 );
4343 }
4444
4545 /**
Index: trunk/phase3/includes/upload/UploadBase.php
@@ -742,7 +742,6 @@
743743 * This method returns the file object, which also has a 'fileKey' property which can be passed through a form or
744744 * API request to find this stashed file again.
745745 *
746 - * @param $key String: (optional) the file key used to find the file info again. If not supplied, a key will be autogenerated.
747746 * @return UploadStashFile stashed file
748747 */
749748 public function stashFile() {
@@ -757,7 +756,6 @@
758757 /**
759758 * Stash a file in a temporary directory, returning a key which can be used to find the file again. See stashFile().
760759 *
761 - * @param $key String: (optional) the file key used to find the file info again. If not supplied, a key will be autogenerated.
762760 * @return String: file key
763761 */
764762 public function stashFileGetKey() {
@@ -767,7 +765,6 @@
768766 /**
769767 * alias for stashFileGetKey, for backwards compatibility
770768 *
771 - * @param $key String: (optional) the file key used to find the file info again. If not supplied, a key will be autogenerated.
772769 * @return String: file key
773770 */
774771 public function stashSession() {
Index: trunk/phase3/includes/upload/UploadStash.php
@@ -96,7 +96,7 @@
9797 if ( !isset( $this->fileMetadata[$key] ) ) {
9898 if ( !$this->fetchFileMetadata( $key ) ) {
9999 // 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 );
101101 }
102102
103103 if ( !isset( $this->fileMetadata[$key] ) ) {
@@ -155,7 +155,6 @@
156156 *
157157 * @param $path String: path to file you want stashed
158158 * @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
160159 * @throws UploadStashBadPathException
161160 * @throws UploadStashFileException
162161 * @throws UploadStashNotLoggedInException
@@ -248,7 +247,6 @@
249248 'us_status' => 'finished'
250249 );
251250
252 - // if a row exists but previous checks on it passed, let the current user take over this key.
253251 $dbw->insert(
254252 'uploadstash',
255253 $this->fileMetadata[$key],
@@ -424,10 +422,10 @@
425423 * @param $key String: key
426424 * @return boolean
427425 */
428 - protected function fetchFileMetadata( $key, $readFromMaster = false ) {
 426+ protected function fetchFileMetadata( $key, $readFromDB = DB_SLAVE ) {
429427 // populate $fileMetadata[$key]
430428 $dbr = null;
431 - if( $readFromMaster ) {
 429+ if( $readFromDB === DB_MASTER ) {
432430 // sometimes reading from the master is necessary, if there's replication lag.
433431 $dbr = $this->repo->getMasterDb();
434432 } else {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94536Fixed incorrect usage of || operator, added test...raindrift18:10, 15 August 2011
r94592Removed complex replag handling, now just query master when record isn't pres...raindrift23:40, 15 August 2011
r94594Removed the ability to pass a key into stashFile(), which simplifies the stas...raindrift23:58, 15 August 2011

Status & tagging log