Index: trunk/phase3/includes/filerepo/FSRepo.php |
— | — | @@ -237,6 +237,25 @@ |
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
| 241 | + * Remove a temporary file or mark it for garbage collection |
| 242 | + * @param string $virtualUrl The virtual URL returned by storeTemp |
| 243 | + * @return boolean True on success, false on failure |
| 244 | + */ |
| 245 | + function freeTemp( $virtualUrl ) { |
| 246 | + $temp = 'mwrepo:///temp'; |
| 247 | + if ( substr( $virtualUrl, 0, strlen( $temp ) ) != $temp ) { |
| 248 | + wfDebug( __METHOD__.": Invalid virtual URL\n" ); |
| 249 | + return false; |
| 250 | + } |
| 251 | + $path = $this->resolveVirtualUrl( $virtualUrl ); |
| 252 | + wfSuppressWarnings(); |
| 253 | + $success = unlink( $path ); |
| 254 | + wfRestoreWarnings(); |
| 255 | + return $success; |
| 256 | + } |
| 257 | + |
| 258 | + |
| 259 | + /** |
241 | 260 | * Copy or move a file either from the local filesystem or from an mwrepo:// |
242 | 261 | * virtual URL, into this repository at the specified destination location. |
243 | 262 | * |
Index: trunk/phase3/includes/SpecialUpload.php |
— | — | @@ -368,17 +368,18 @@ |
369 | 369 | if( $veri !== true ) { //it's a wiki error... |
370 | 370 | return $this->uploadError( $veri->toString() ); |
371 | 371 | } |
372 | | - } |
373 | 372 | |
374 | | - /** |
375 | | - * Provide an opportunity for extensions to add futher checks |
376 | | - */ |
377 | | - $error = ''; |
378 | | - if( !wfRunHooks( 'UploadVerification', |
379 | | - array( $this->mUploadSaveName, $this->mUploadTempName, &$error ) ) ) { |
380 | | - return $this->uploadError( $error ); |
| 373 | + /** |
| 374 | + * Provide an opportunity for extensions to add futher checks |
| 375 | + */ |
| 376 | + $error = ''; |
| 377 | + if( !wfRunHooks( 'UploadVerification', |
| 378 | + array( $this->mUploadSaveName, $this->mUploadTempName, &$error ) ) ) { |
| 379 | + return $this->uploadError( $error ); |
| 380 | + } |
381 | 381 | } |
382 | 382 | |
| 383 | + |
383 | 384 | /** |
384 | 385 | * Check for non-fatal conditions |
385 | 386 | */ |
— | — | @@ -602,9 +603,8 @@ |
603 | 604 | */ |
604 | 605 | function unsaveUploadedFile() { |
605 | 606 | global $wgOut; |
606 | | - wfSuppressWarnings(); |
607 | | - $success = unlink( $this->mUploadTempName ); |
608 | | - wfRestoreWarnings(); |
| 607 | + $repo = RepoGroup::singleton()->getLocalRepo(); |
| 608 | + $success = $repo->freeTemp( $this->mUploadTempName ); |
609 | 609 | if ( ! $success ) { |
610 | 610 | $wgOut->showFileDeleteError( $this->mUploadTempName ); |
611 | 611 | return false; |