r26236 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26235‎ | r26236 | r26237 >
Date:05:20, 29 September 2007
Author:yurik
Status:old
Tags:
Comment:
Synced with the root. This is the version that is being merged with the trunk.
Modified paths:
  • /branches/ApiEdit_Vodafone/includes/SpecialUpload.php (modified) (history)

Diff [purge]

Index: branches/ApiEdit_Vodafone/includes/SpecialUpload.php
@@ -278,69 +278,64 @@
279279 $details = null;
280280 $value = null;
281281 $value = $this->internalProcessUpload( $details );
 282+
282283 switch($value) {
283284 case self::SUCCESS:
284285 $wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() );
285 - break;
 286+ return;
286287
287288 case self::BEFORE_PROCESSING:
288289 return false;
289 - break;
290290
291291 case self::LARGE_FILE_SERVER:
292292 $this->mainUploadForm( wfMsgHtml( 'largefileserver' ) );
293 - break;
 293+ return;
294294
295295 case self::EMPTY_FILE:
296296 $this->mainUploadForm( wfMsgHtml( 'emptyfile' ) );
297 - break;
 297+ return;
298298
299299 case self::MIN_LENGHT_PARTNAME:
300300 $this->mainUploadForm( wfMsgHtml( 'minlength1' ) );
301 - break;
 301+ return;
302302
303303 case self::ILLEGAL_FILENAME:
304304 $filtered = $details['filtered'];
305305 $this->uploadError( wfMsgWikiHtml( 'illegalfilename', htmlspecialchars( $filtered ) ) );
306 - break;
 306+ return;
307307
308308 case self::PROTECTED_PAGE:
309 - $this->uploadError( wfMsgWikiHtml( 'protectedpage' ) );
310 - break;
 309+ return $this->uploadError( wfMsgWikiHtml( 'protectedpage' ) );
311310
312311 case self::OVERWRITE_EXISTING_FILE:
313 - $overwrite = $details['overwrite'];
314 - $overwrite = new WikiError( $wgOut->parse( $overwrite ) );
 312+ $errorText = $details['overwrite'];
 313+ $overwrite = new WikiError( $wgOut->parse( $errorText ) );
 314+ return $this->uploadError( $overwrite->toString() );
315315
316 - if( WikiError::isError( $overwrite ) ) {
317 - $this->uploadError( $overwrite->toString() );
318 - }
319 - break;
320 -
321316 case self::FILETYPE_MISSING:
322 - $this->uploadError( wfMsgExt( 'filetype-missing', array ( 'parseinline' ) ) );
323 - break;
 317+ return $this->uploadError( wfMsgExt( 'filetype-missing', array ( 'parseinline' ) ) );
324318
325319 case self::FILETYPE_BADTYPE:
326320 $finalExt = $details['finalExt'];
327 - $this->uploadError( wfMsgExt( 'filetype-badtype', array ( 'parseinline' ), htmlspecialchars( $finalExt ), implode ( ', ', $wgFileExtensions ) ) );
328 - break;
 321+ return $this->uploadError( wfMsgExt( 'filetype-badtype', array ( 'parseinline' ), htmlspecialchars( $finalExt ), implode ( ', ', $wgFileExtensions ) ) );
329322
330323 case self::VERIFICATION_ERROR:
331324 $veri = $details['veri'];
332 - $this->uploadError( $veri->toString() );
333 - break;
 325+ return $this->uploadError( $veri->toString() );
334326
335327 case self::UPLOAD_VERIFICATION_ERROR:
336328 $error = $details['error'];
337 - $this->uploadError( $error );
338 - break;
 329+ return $this->uploadError( $error );
339330
340331 case self::UPLOAD_WARNING:
341332 $warning = $details['warning'];
342 - $this->uploadWarning( $warning );
343 - break;
 333+ return $this->uploadWarning( $warning );
344334 }
 335+
 336+ /* TODO: Each case returns instead of breaking to maintain the highest level of compatibility during branch merging.
 337+ They should be reviewed and corrected separatelly.
 338+ */
 339+ new MWException( __METHOD__ . ": Unknown value `{$value}`" );
345340 }
346341
347342 /**
@@ -358,7 +353,6 @@
359354 {
360355 wfDebug( "Hook 'UploadForm:BeforeProcessing' broke processing the file." );
361356 return self::BEFORE_PROCESSING;
362 -
363357 }
364358
365359 /* Check for PHP error if any, requires php 4.2 or newer */
@@ -400,7 +394,6 @@
401395 $partname .= '.' . $ext[$i];
402396 }
403397
404 -
405398 if( strlen( $partname ) < 1 ) {
406399 return self::MIN_LENGHT_PARTNAME;
407400 }
@@ -411,7 +404,6 @@
412405 */
413406 $filtered = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $filtered );
414407 $nt = Title::makeTitleSafe( NS_IMAGE, $filtered );
415 -
416408 if( is_null( $nt ) ) {
417409 $resultDetails = array( 'filtered' => $filtered );
418410 return self::ILLEGAL_FILENAME;
@@ -431,8 +423,7 @@
432424 * In some cases we may forbid overwriting of existing files.
433425 */
434426 $overwrite = $this->checkOverwrite( $this->mDestName );
435 -
436 - if( !is_null( $overwrite ) && $overwrite != 1 ) {
 427+ if( $overwrite !== true ) {
437428 $resultDetails = array( 'overwrite' => $overwrite );
438429 return self::OVERWRITE_EXISTING_FILE;
439430 }
@@ -440,10 +431,8 @@
441432 /* Don't allow users to override the blacklist (check file extension) */
442433 global $wgStrictFileExtensions;
443434 global $wgFileExtensions, $wgFileBlacklist;
444 -
445435 if ($finalExt == '') {
446436 return self::FILETYPE_MISSING;
447 -
448437 } elseif ( $this->checkFileExtensionList( $ext, $wgFileBlacklist ) ||
449438 ($wgStrictFileExtensions && !$this->checkFileExtension( $finalExt, $wgFileExtensions ) ) ) {
450439 $resultDetails = array( 'finalExt' => $finalExt );
@@ -482,6 +471,7 @@
483472 */
484473 if ( ! $this->mIgnoreWarning ) {
485474 $warning = '';
 475+
486476 global $wgCapitalLinks;
487477 if( $wgCapitalLinks ) {
488478 $filtered = ucfirst( $filtered );
@@ -512,7 +502,6 @@
513503 if ( !$this->mDestWarningAck ) {
514504 $warning .= self::getExistsWarning( $this->mLocalFile );
515505 }
516 -
517506 if( $warning != '' ) {
518507 /**
519508 * Stash the file in a temporary location; the user can choose

Follow-up revisions

RevisionCommit summaryAuthorDate
r26237Merged from apiedit_vodafone branch, r26236....yurik05:32, 29 September 2007
r26257Merged revisions 26134-26247 via svnmerge from...david19:06, 30 September 2007

Status & tagging log