r61372 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61371‎ | r61372 | r61373 >
Date:17:56, 22 January 2010
Author:travis
Status:deferred (Comments)
Tags:
Comment:
bug fix for 22012, will only work with Mediawiki 1.16+
Modified paths:
  • /trunk/extensions/ImportFreeImages/ImportFreeImages.body.php (modified) (history)
  • /trunk/extensions/ImportFreeImages/ImportFreeImages.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ImportFreeImages/ImportFreeImages.body.php
@@ -177,7 +177,7 @@
178178
179179 /**
180180 * Shows a custom upload warning
181 - * @param $u UploadForm object
 181+ * @param $u UploadFromFile object
182182 * @param $warning Mixed: warning message (MediaWiki:Fileexists plus some other stuff)
183183 */
184184 function wfIFI_uploadWarning( $u, $warning ) {
@@ -185,6 +185,11 @@
186186
187187 wfLoadExtensionMessages( 'ImportFreeImages' );
188188
 189+ $form = new UploadForm();
 190+ $form->mUpload = $u;
 191+ $form->uploadWarning();
 192+ return;
 193+
189194 $u->mSessionKey = $u->stashSession();
190195 if( !$u->mSessionKey ) {
191196 # Couldn't save file; an error has been displayed so let's go.
@@ -304,20 +309,6 @@
305310 $caption = trim($caption);
306311 }
307312
308 - // UploadForm class should be autoloaded by now on MediaWiki 1.13+
309 - // But on older versions, we need to require_once() it manually
310 - if( !class_exists( 'UploadForm' ) ){
311 - require_once('includes/SpecialUpload.php');
312 - }
313 - $u = new UploadForm($wgRequest);
314 - // TODO: we should use FauxRequest here instead of accessing member variables.
315 - // But FauxRequest doesn't yet allow us to pass files around
316 - $u->mTempPath = $tempname;
317 - $u->mFileSize = $size;
318 - $u->mComment = $caption;
319 - $u->mRemoveTempFile = true;
320 - $u->mIgnoreWarning = true;
321 -
322313 $filename = $ititle . ($wgIFI_AppendRandomNumber ? "-" . rand(0, 9999) : "") . $fileext;
323314 $filename = preg_replace('/ +/', ' ', $filename);
324315 /**
@@ -331,7 +322,8 @@
332323 $wgOut->showErrorPage( 'error', 'illegalfilename', array( wfEscapeWikiText( $filename ) ) );
333324 return false;
334325 }
335 - $u->mSrcName = $filename;
 326+ $u = new UploadFromFile();
 327+ $u->initialize($filename, $tempname, $size, true);
336328
337329 if( $nt->getArticleID() > 0 ) {
338330 $sk = $wgUser->getSkin();
@@ -345,8 +337,16 @@
346338 $wgOut->showPermissionsErrorPage( $nt->getUserPermissionsErrors( 'create', $wgUser ) );
347339 return false;
348340 } else {
349 - $u->execute();
350 - return true;
 341+ $status = $u->performUpload(wfMsg('importfreeimages_comment'), $caption, false, $wgUser);
 342+ if ( !$status->isGood() ) {
 343+ $form = new UploadForm();
 344+ $form->mUppload = $u;
 345+ $form->uploadError( $wgOut->parse( $status->getWikiText() ) );
 346+ }
 347+ // Success, redirect to description page
 348+ wfRunHooks( 'SpecialUploadComplete', array( &$this ) );
 349+ $local = $u->getLocalFile();
 350+ $wgOut->redirect( $local->getTitle()->getFullURL() );
351351 }
352352 }
353353
Index: trunk/extensions/ImportFreeImages/ImportFreeImages.i18n.php
@@ -26,6 +26,7 @@
2727 'importfreeimages_promptuserforfilename' => 'Please enter a destination filename:',
2828 'importfreeimages_returntoform' => 'Or, click <a href=\'$1\'>here</a> to return to your search results',
2929 'importfreeimages_nophpflickr' => 'You have not installed phpFlickr, please set $wgIFphpFlickr in your LocalSettings.php.',
 30+ 'importfreeimages_comment' => "Importing image from Flickr",
3031 );
3132
3233 /** Message documentation (Message documentation)

Comments

#Comment by Bryan (talk | contribs)   18:01, 22 January 2010

I'm not sure whether you tested this against a recent revision of chunck, but I'm pretty sure that the following lines:

+				$form->mUppload = $u;
+            	$form->uploadError( $wgOut->parse( $status->getWikiText() ) );

should be:

$form->mUpload = $u;
$form->showUploadError( ... )

Status & tagging log