From 9e25ce6e0d95ccf7aba7f47470dc562ed3a26beb Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Fri, 3 Dec 2010 11:29:55 +0000 Subject: [PATCH] Allow the submit callback function to return a Status object (will use this later for other forms) --- includes/HTMLForm.php | 9 +++++++-- includes/Preferences.php | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index c51a9a8e97..fff1b40c48 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -209,7 +209,9 @@ class HTMLForm { $result = $this->trySubmit(); } - if ( $result === true ) { + if ( $result === true || + ( $result instanceof Status && $result->isGood() ) ) + { return $result; } @@ -460,7 +462,10 @@ class HTMLForm { * @return String */ function getErrors( $errors ) { - if ( is_array( $errors ) ) { + if ( $errors instanceof Status ) { + global $wgOut; + $errorstr = $wgOut->parse( $errors->getWikiText() ); + } elseif ( is_array( $errors ) ) { $errorstr = $this->formatErrors( $errors ); } else { $errorstr = $errors; diff --git a/includes/Preferences.php b/includes/Preferences.php index b9b120cb3d..deb17d088f 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -1328,7 +1328,7 @@ class Preferences { $wgOut->redirect( $url ); } - return true; + return Status::newGood(); } public static function loadOldSearchNs( $user ) { -- 2.20.1