Cleaning up little things, updates to code clarity, documentation fixes per Catrope's suggestions.

followup to r94536, r94592, r94594
This commit is contained in:
Ian Baker 2011-08-16 17:57:32 +00:00
parent c34a569d51
commit a26afff4e0
3 changed files with 4 additions and 9 deletions

View 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() {

View 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 );
}
/**

View 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 {