* 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() {
/**
* 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() {
/**
* 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() {
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] ) ) {
*
* @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
'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],
* @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 {