Index: trunk/phase3/includes/upload/UploadFromStash.php |
— | — | @@ -100,10 +100,10 @@ |
101 | 101 | * There is no need to stash the image twice |
102 | 102 | */ |
103 | 103 | public function stashFile( $key = null ) { |
104 | | - if ( !empty( $this->mFileKey ) ) { |
105 | | - return $this->mFileKey; |
| 104 | + if ( !empty( $this->mLocalFile ) ) { |
| 105 | + return $this->mLocalFile; |
106 | 106 | } |
107 | | - return parent::stashFileGetKey(); |
| 107 | + return parent::stashFile( $key ); |
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
— | — | @@ -118,7 +118,16 @@ |
119 | 119 | * @return success |
120 | 120 | */ |
121 | 121 | public function unsaveUploadedFile() { |
122 | | - return $stash->removeFile( $this->mFileKey ); |
| 122 | + return $this->stash->removeFile( $this->mFileKey ); |
123 | 123 | } |
124 | 124 | |
| 125 | + /** |
| 126 | + * Perform the upload, then remove the database record afterward. |
| 127 | + */ |
| 128 | + public function performUpload( $comment, $pageText, $watch, $user ) { |
| 129 | + $rv = parent::performUpload( $comment, $pageText, $watch, $user ); |
| 130 | + $this->unsaveUploadedFile(); |
| 131 | + return $rv; |
| 132 | + } |
| 133 | + |
125 | 134 | } |
\ No newline at end of file |
Index: trunk/phase3/includes/upload/UploadBase.php |
— | — | @@ -589,7 +589,7 @@ |
590 | 590 | if ( $watch ) { |
591 | 591 | $user->addWatch( $this->getLocalFile()->getTitle() ); |
592 | 592 | } |
593 | | - |
| 593 | + |
594 | 594 | wfRunHooks( 'UploadComplete', array( &$this ) ); |
595 | 595 | } |
596 | 596 | |
Index: trunk/phase3/includes/upload/UploadStash.php |
— | — | @@ -131,6 +131,11 @@ |
132 | 132 | $this->fileProps[$key] = File::getPropsFromPath( $path ); |
133 | 133 | } |
134 | 134 | |
| 135 | + if ( ! $this->files[$key]->exists() ) { |
| 136 | + wfDebug( __METHOD__ . " tried to get file at $key, but it doesn't exist\n" ); |
| 137 | + throw new UploadStashBadPathException( "path doesn't exist" ); |
| 138 | + } |
| 139 | + |
135 | 140 | if( !$noAuth ) { |
136 | 141 | if( $this->fileMetadata[$key]['us_user'] != $this->userId ) { |
137 | 142 | throw new UploadStashWrongOwnerException( "This file ($key) doesn't belong to the current user." ); |
— | — | @@ -671,6 +676,10 @@ |
672 | 677 | return $this->repo->freeTemp( $this->path ); |
673 | 678 | } |
674 | 679 | |
| 680 | + public function exists() { |
| 681 | + return $this->repo->fileExists( $this->path, FileRepo::FILES_ONLY ); |
| 682 | + } |
| 683 | + |
675 | 684 | } |
676 | 685 | |
677 | 686 | class UploadStashNotAvailableException extends MWException {}; |
Index: trunk/phase3/includes/api/ApiUpload.php |
— | — | @@ -147,6 +147,7 @@ |
148 | 148 | */ |
149 | 149 | function performStash() { |
150 | 150 | try { |
| 151 | + xdebug_break(); |
151 | 152 | $fileKey = $this->mUpload->stashFile()->getFileKey(); |
152 | 153 | } catch ( MWException $e ) { |
153 | 154 | $message = 'Stashing temporary file failed: ' . get_class( $e ) . ' ' . $e->getMessage(); |