r76666 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76665‎ | r76666 | r76667 >
Date:19:13, 14 November 2010
Author:ialex
Status:ok
Tags:
Comment:
Convert WikiError -> Status
Modified paths:
  • /trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php (modified) (history)
  • /trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SocialProfile/SystemGifts/SpecialSystemGiftManagerLogo.php
@@ -183,8 +183,8 @@
184184 if ( !$this->mStashed ) {
185185 $veri = $this->verify( $this->mUploadTempName, $finalExt );
186186
187 - if ( $veri !== true ) { // it's a wiki error...
188 - return $this->uploadError( $veri->toString() );
 187+ if ( !$veri->isGood() ) {
 188+ return $this->uploadError( $wgOut->parse( $veri->getWikiText() ) );
189189 }
190190 }
191191
@@ -663,7 +663,7 @@
664664 *
665665 * @param string $tmpfile the full path opf the temporary file to verify
666666 * @param string $extension The filename extension that the file is to be served with
667 - * @return mixed true of the file is verified, a WikiError object otherwise.
 667+ * @return Status object
668668 */
669669 function verify( $tmpfile, $extension ) {
670670 # magically determine mime type
@@ -675,20 +675,20 @@
676676 if ( $wgVerifyMimeType ) {
677677 # check mime type against file extension
678678 if ( !$this->verifyExtension( $mime, $extension ) ) {
679 - return new WikiErrorMsg( 'uploadcorrupt' );
 679+ return Status::newFatal( 'uploadcorrupt' );
680680 }
681681
682682 # check mime type blacklist
683683 global $wgMimeTypeBlacklist;
684684 if ( isset( $wgMimeTypeBlacklist ) && !is_null( $wgMimeTypeBlacklist )
685685 && $this->checkFileExtension( $mime, $wgMimeTypeBlacklist ) ) {
686 - return new WikiErrorMsg( 'badfiletype', htmlspecialchars( $mime ) );
 686+ return Status::newFatal( 'badfiletype', htmlspecialchars( $mime ) );
687687 }
688688 }
689689
690690 # check for htmlish code and javascript
691691 if ( $this->detectScript( $tmpfile, $mime ) ) {
692 - return new WikiErrorMsg( 'uploadscripted' );
 692+ return Status::newFatal( 'uploadscripted' );
693693 }
694694
695695 /**
@@ -696,11 +696,11 @@
697697 */
698698 $virus = $this->detectVirus( $tmpfile );
699699 if ( $virus ) {
700 - return new WikiErrorMsg( 'uploadvirus', htmlspecialchars( $virus ) );
 700+ return Status::newFatal( 'uploadvirus', htmlspecialchars( $virus ) );
701701 }
702702
703703 wfDebug( __METHOD__ . ": all clear; passing.\n" );
704 - return true;
 704+ return Status::newGood();
705705 }
706706
707707 /**
Index: trunk/extensions/SocialProfile/UserGifts/SpecialGiftManagerLogo.php
@@ -186,8 +186,8 @@
187187 if ( !$this->mStashed ) {
188188 $veri = $this->verify( $this->mUploadTempName, $finalExt );
189189
190 - if ( $veri !== true ) { // it's a wiki error...
191 - return $this->uploadError( $veri->toString() );
 190+ if ( !$veri->isGood() ) {
 191+ return $this->uploadError( $wgOut->parse( $veri->getWikiText() ) );
192192 }
193193 }
194194
@@ -651,7 +651,7 @@
652652 *
653653 * @param string $tmpfile the full path opf the temporary file to verify
654654 * @param string $extension The filename extension that the file is to be served with
655 - * @return mixed true of the file is verified, a WikiError object otherwise.
 655+ * @return Status object
656656 */
657657 function verify( $tmpfile, $extension ) {
658658 # magically determine mime type
@@ -664,20 +664,20 @@
665665
666666 # check mime type against file extension
667667 if ( !$this->verifyExtension( $mime, $extension ) ) {
668 - return new WikiErrorMsg( 'uploadcorrupt' );
 668+ return Status::newFatal( 'uploadcorrupt' );
669669 }
670670
671671 # check mime type blacklist
672672 global $wgMimeTypeBlacklist;
673673 if ( isset( $wgMimeTypeBlacklist ) && !is_null( $wgMimeTypeBlacklist )
674674 && $this->checkFileExtension( $mime, $wgMimeTypeBlacklist ) ) {
675 - return new WikiErrorMsg( 'badfiletype', htmlspecialchars( $mime ) );
 675+ return Status::newFatal( 'badfiletype', htmlspecialchars( $mime ) );
676676 }
677677 }
678678
679679 # check for htmlish code and javascript
680680 if ( $this->detectScript( $tmpfile, $mime ) ) {
681 - return new WikiErrorMsg( 'uploadscripted' );
 681+ return Status::newFatal( 'uploadscripted' );
682682 }
683683
684684 /**
@@ -685,11 +685,11 @@
686686 */
687687 $virus = $this->detectVirus( $tmpfile );
688688 if ( $virus ) {
689 - return new WikiErrorMsg( 'uploadvirus', htmlspecialchars( $virus ) );
 689+ return Status::newFatal( 'uploadvirus', htmlspecialchars( $virus ) );
690690 }
691691
692692 wfDebug( __METHOD__ . ": all clear; passing.\n" );
693 - return true;
 693+ return Status::newGood();
694694 }
695695
696696 /**

Status & tagging log