r22675 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22674‎ | r22675 | r22676 >
Date:11:23, 3 June 2007
Author:tstarling
Status:old
Tags:
Comment:
Fix SpecialUpload::unsaveUploadedFile(). Move UploadVerification hook so that it is only called as the file is uploaded, so that extensions don't die when fed an mwrepo:// URL.
Modified paths:
  • /trunk/phase3/includes/SpecialUpload.php (modified) (history)
  • /trunk/phase3/includes/filerepo/FSRepo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/filerepo/FSRepo.php
@@ -237,6 +237,25 @@
238238 }
239239
240240 /**
 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+ /**
241260 * Copy or move a file either from the local filesystem or from an mwrepo://
242261 * virtual URL, into this repository at the specified destination location.
243262 *
Index: trunk/phase3/includes/SpecialUpload.php
@@ -368,17 +368,18 @@
369369 if( $veri !== true ) { //it's a wiki error...
370370 return $this->uploadError( $veri->toString() );
371371 }
372 - }
373372
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+ }
381381 }
382382
 383+
383384 /**
384385 * Check for non-fatal conditions
385386 */
@@ -602,9 +603,8 @@
603604 */
604605 function unsaveUploadedFile() {
605606 global $wgOut;
606 - wfSuppressWarnings();
607 - $success = unlink( $this->mUploadTempName );
608 - wfRestoreWarnings();
 607+ $repo = RepoGroup::singleton()->getLocalRepo();
 608+ $success = $repo->freeTemp( $this->mUploadTempName );
609609 if ( ! $success ) {
610610 $wgOut->showFileDeleteError( $this->mUploadTempName );
611611 return false;

Follow-up revisions

RevisionCommit summaryAuthorDate
r22717Merged revisions 22667-22715 via svnmerge from...david20:00, 4 June 2007

Status & tagging log