Index: branches/ApiEdit_Vodafone/includes/SpecialUpload.php |
— | — | @@ -278,69 +278,64 @@ |
279 | 279 | $details = null; |
280 | 280 | $value = null; |
281 | 281 | $value = $this->internalProcessUpload( $details ); |
| 282 | + |
282 | 283 | switch($value) { |
283 | 284 | case self::SUCCESS: |
284 | 285 | $wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() ); |
285 | | - break; |
| 286 | + return; |
286 | 287 | |
287 | 288 | case self::BEFORE_PROCESSING: |
288 | 289 | return false; |
289 | | - break; |
290 | 290 | |
291 | 291 | case self::LARGE_FILE_SERVER: |
292 | 292 | $this->mainUploadForm( wfMsgHtml( 'largefileserver' ) ); |
293 | | - break; |
| 293 | + return; |
294 | 294 | |
295 | 295 | case self::EMPTY_FILE: |
296 | 296 | $this->mainUploadForm( wfMsgHtml( 'emptyfile' ) ); |
297 | | - break; |
| 297 | + return; |
298 | 298 | |
299 | 299 | case self::MIN_LENGHT_PARTNAME: |
300 | 300 | $this->mainUploadForm( wfMsgHtml( 'minlength1' ) ); |
301 | | - break; |
| 301 | + return; |
302 | 302 | |
303 | 303 | case self::ILLEGAL_FILENAME: |
304 | 304 | $filtered = $details['filtered']; |
305 | 305 | $this->uploadError( wfMsgWikiHtml( 'illegalfilename', htmlspecialchars( $filtered ) ) ); |
306 | | - break; |
| 306 | + return; |
307 | 307 | |
308 | 308 | case self::PROTECTED_PAGE: |
309 | | - $this->uploadError( wfMsgWikiHtml( 'protectedpage' ) ); |
310 | | - break; |
| 309 | + return $this->uploadError( wfMsgWikiHtml( 'protectedpage' ) ); |
311 | 310 | |
312 | 311 | 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() ); |
315 | 315 | |
316 | | - if( WikiError::isError( $overwrite ) ) { |
317 | | - $this->uploadError( $overwrite->toString() ); |
318 | | - } |
319 | | - break; |
320 | | - |
321 | 316 | case self::FILETYPE_MISSING: |
322 | | - $this->uploadError( wfMsgExt( 'filetype-missing', array ( 'parseinline' ) ) ); |
323 | | - break; |
| 317 | + return $this->uploadError( wfMsgExt( 'filetype-missing', array ( 'parseinline' ) ) ); |
324 | 318 | |
325 | 319 | case self::FILETYPE_BADTYPE: |
326 | 320 | $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 ) ) ); |
329 | 322 | |
330 | 323 | case self::VERIFICATION_ERROR: |
331 | 324 | $veri = $details['veri']; |
332 | | - $this->uploadError( $veri->toString() ); |
333 | | - break; |
| 325 | + return $this->uploadError( $veri->toString() ); |
334 | 326 | |
335 | 327 | case self::UPLOAD_VERIFICATION_ERROR: |
336 | 328 | $error = $details['error']; |
337 | | - $this->uploadError( $error ); |
338 | | - break; |
| 329 | + return $this->uploadError( $error ); |
339 | 330 | |
340 | 331 | case self::UPLOAD_WARNING: |
341 | 332 | $warning = $details['warning']; |
342 | | - $this->uploadWarning( $warning ); |
343 | | - break; |
| 333 | + return $this->uploadWarning( $warning ); |
344 | 334 | } |
| 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}`" ); |
345 | 340 | } |
346 | 341 | |
347 | 342 | /** |
— | — | @@ -358,7 +353,6 @@ |
359 | 354 | { |
360 | 355 | wfDebug( "Hook 'UploadForm:BeforeProcessing' broke processing the file." ); |
361 | 356 | return self::BEFORE_PROCESSING; |
362 | | - |
363 | 357 | } |
364 | 358 | |
365 | 359 | /* Check for PHP error if any, requires php 4.2 or newer */ |
— | — | @@ -400,7 +394,6 @@ |
401 | 395 | $partname .= '.' . $ext[$i]; |
402 | 396 | } |
403 | 397 | |
404 | | - |
405 | 398 | if( strlen( $partname ) < 1 ) { |
406 | 399 | return self::MIN_LENGHT_PARTNAME; |
407 | 400 | } |
— | — | @@ -411,7 +404,6 @@ |
412 | 405 | */ |
413 | 406 | $filtered = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $filtered ); |
414 | 407 | $nt = Title::makeTitleSafe( NS_IMAGE, $filtered ); |
415 | | - |
416 | 408 | if( is_null( $nt ) ) { |
417 | 409 | $resultDetails = array( 'filtered' => $filtered ); |
418 | 410 | return self::ILLEGAL_FILENAME; |
— | — | @@ -431,8 +423,7 @@ |
432 | 424 | * In some cases we may forbid overwriting of existing files. |
433 | 425 | */ |
434 | 426 | $overwrite = $this->checkOverwrite( $this->mDestName ); |
435 | | - |
436 | | - if( !is_null( $overwrite ) && $overwrite != 1 ) { |
| 427 | + if( $overwrite !== true ) { |
437 | 428 | $resultDetails = array( 'overwrite' => $overwrite ); |
438 | 429 | return self::OVERWRITE_EXISTING_FILE; |
439 | 430 | } |
— | — | @@ -440,10 +431,8 @@ |
441 | 432 | /* Don't allow users to override the blacklist (check file extension) */ |
442 | 433 | global $wgStrictFileExtensions; |
443 | 434 | global $wgFileExtensions, $wgFileBlacklist; |
444 | | - |
445 | 435 | if ($finalExt == '') { |
446 | 436 | return self::FILETYPE_MISSING; |
447 | | - |
448 | 437 | } elseif ( $this->checkFileExtensionList( $ext, $wgFileBlacklist ) || |
449 | 438 | ($wgStrictFileExtensions && !$this->checkFileExtension( $finalExt, $wgFileExtensions ) ) ) { |
450 | 439 | $resultDetails = array( 'finalExt' => $finalExt ); |
— | — | @@ -482,6 +471,7 @@ |
483 | 472 | */ |
484 | 473 | if ( ! $this->mIgnoreWarning ) { |
485 | 474 | $warning = ''; |
| 475 | + |
486 | 476 | global $wgCapitalLinks; |
487 | 477 | if( $wgCapitalLinks ) { |
488 | 478 | $filtered = ucfirst( $filtered ); |
— | — | @@ -512,7 +502,6 @@ |
513 | 503 | if ( !$this->mDestWarningAck ) { |
514 | 504 | $warning .= self::getExistsWarning( $this->mLocalFile ); |
515 | 505 | } |
516 | | - |
517 | 506 | if( $warning != '' ) { |
518 | 507 | /** |
519 | 508 | * Stash the file in a temporary location; the user can choose |