*/
function performStash() {
try {
+ xdebug_break();
$fileKey = $this->mUpload->stashFile()->getFileKey();
} catch ( MWException $e ) {
$message = 'Stashing temporary file failed: ' . get_class( $e ) . ' ' . $e->getMessage();
* There is no need to stash the image twice
*/
public function stashFile( $key = null ) {
- if ( !empty( $this->mFileKey ) ) {
- return $this->mFileKey;
+ if ( !empty( $this->mLocalFile ) ) {
+ return $this->mLocalFile;
}
- return parent::stashFileGetKey();
+ return parent::stashFile( $key );
}
/**
* @return success
*/
public function unsaveUploadedFile() {
- return $stash->removeFile( $this->mFileKey );
+ return $this->stash->removeFile( $this->mFileKey );
+ }
+
+ /**
+ * Perform the upload, then remove the database record afterward.
+ */
+ public function performUpload( $comment, $pageText, $watch, $user ) {
+ $rv = parent::performUpload( $comment, $pageText, $watch, $user );
+ $this->unsaveUploadedFile();
+ return $rv;
}
}
\ No newline at end of file
$this->fileProps[$key] = File::getPropsFromPath( $path );
}
+ if ( ! $this->files[$key]->exists() ) {
+ wfDebug( __METHOD__ . " tried to get file at $key, but it doesn't exist\n" );
+ throw new UploadStashBadPathException( "path doesn't exist" );
+ }
+
if( !$noAuth ) {
if( $this->fileMetadata[$key]['us_user'] != $this->userId ) {
throw new UploadStashWrongOwnerException( "This file ($key) doesn't belong to the current user." );
return $this->repo->freeTemp( $this->path );
}
+ public function exists() {
+ return $this->repo->fileExists( $this->path, FileRepo::FILES_ONLY );
+ }
+
}
class UploadStashNotAvailableException extends MWException {};