From: Ian Baker Date: Tue, 16 Aug 2011 17:57:32 +0000 (+0000) Subject: Cleaning up little things, updates to code clarity, documentation fixes per Catrope... X-Git-Tag: 1.31.0-rc.0~28229 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=a26afff4e062f72645bf933e5f8317aee649feda;p=lhc%2Fweb%2Fwiklou.git Cleaning up little things, updates to code clarity, documentation fixes per Catrope's suggestions. followup to r94536, r94592, r94594 --- diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index 429a363bbd..443b7c9ea5 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -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() { diff --git a/includes/upload/UploadFromStash.php b/includes/upload/UploadFromStash.php index a2f9be59c6..22a92f3ae2 100644 --- a/includes/upload/UploadFromStash.php +++ b/includes/upload/UploadFromStash.php @@ -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 ); } /** diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index cad8585088..9bdcc1b63b 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -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 {