Fix up getMessage() on WikiError
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 17 Jun 2005 23:20:55 +0000 (23:20 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 17 Jun 2005 23:20:55 +0000 (23:20 +0000)
includes/SpecialImport.php
includes/SpecialPreferences.php
includes/WikiError.php

index 3903de0..09bc312 100644 (file)
@@ -54,13 +54,13 @@ function wfSpecialImport( $page = '' ) {
                }
                
                if( WikiError::isError( $result ) ) {
-                       $wgOut->addWikiText( htmlspecialchars( $result->toString() ) );
+                       $wgOut->addWikiText( wfEscapeWikiText( $result->getMessage() ) );
                } else {
                        $importer->setRevisionHandler( "wfImportOldRevision" );
                        $result = $importer->doImport();
                        if( WikiError::isError( $result ) ) {
                                $wgOut->addHTML( "<p>" . wfMsg( "importfailed",
-                                       htmlspecialchars( $result->toString() ) ) . "</p>" );
+                                       htmlspecialchars( $result->getMessage() ) ) . "</p>" );
                        } else {
                                # Success!
                                $wgOut->addHTML( "<p>" . wfMsg( "importsuccess" ) . "</p>" );
index 56138e9..4ebcb36 100644 (file)
@@ -261,7 +261,7 @@ class PreferencesForm {
                                                # User can come back through the confirmation URL to re-enable email.
                                                $result = $wgUser->sendConfirmationMail();
                                                if( WikiError::isError( $result ) ) {
-                                                       $error = wfMsg( 'mailerror', $result->toString() );
+                                                       $error = wfMsg( 'mailerror', $result->getMessage() );
                                                } else {
                                                        $error = wfMsg( 'eauthentsent', $wgUser->getName() );
                                                }
index 65a6455..ece931f 100644 (file)
@@ -37,10 +37,19 @@ class WikiError {
        /**
         * @return string Plaintext error message to display
         */
-       function toString() {
+       function getMessage() {
                return $this->mMessage;
        }
        
+       /**
+        * In following PEAR_Error model this could be formatted differently,
+        * but so far it's not.
+        * @return string
+        */
+       function toString() {
+               return $this->getMessage();
+       }
+       
        /**
         * Returns true if the given object is a WikiError-descended
         * error object, false otherwise.
@@ -83,9 +92,9 @@ class WikiXmlError extends WikiError {
                xml_parser_free( $parser );
        }
        
-       function toString() {
+       function getMessage() {
                return $this->mMessage . ': ' . xml_error_string( $this->mXmlError );
        }
 }
 
-?>
\ No newline at end of file
+?>