From: Bryan Tong Minh Date: Fri, 30 May 2008 19:59:47 +0000 (+0000) Subject: Always return an array if an error has occurred in Title::moveTo. X-Git-Tag: 1.31.0-rc.0~47280 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=f8a7159e6ceb5e23c418460de184bca0ee8a3e6b;p=lhc%2Fweb%2Fwiklou.git Always return an array if an error has occurred in Title::moveTo. --- diff --git a/includes/SpecialMovepage.php b/includes/SpecialMovepage.php index 3188a856c7..faad59318e 100644 --- a/includes/SpecialMovepage.php +++ b/includes/SpecialMovepage.php @@ -273,12 +273,8 @@ class MovePageForm { $error = $ot->moveTo( $nt, true, $this->reason ); if ( $error !== true ) { - # FIXME: moveTo() can return a string - if(is_array($error)) - # FIXME: showForm() should handle multiple errors - call_user_func_array(array($this, 'showForm'), $error[0]); - else - $this->showForm($error); + # FIXME: showForm() should handle multiple errors + call_user_func_array(array($this, 'showForm'), $error[0]); return; } diff --git a/includes/Status.php b/includes/Status.php index 98602cf232..ed1455ca48 100644 --- a/includes/Status.php +++ b/includes/Status.php @@ -170,4 +170,13 @@ class Status { $this->successCount += $other->successCount; $this->failCount += $other->failCount; } + + function getErrorsArray() { + $result = array(); + foreach ( $this->errors as $error ) { + if ( $error['type'] == 'error' ) + $result[] = $error['message']; + } + return $result; + } } diff --git a/includes/Title.php b/includes/Title.php index f7116cc445..a9fff64b99 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2479,7 +2479,7 @@ class Title { */ public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true ) { $err = $this->isValidMoveOperation( $nt, $auth ); - if( is_array($err) ) { + if( is_array( $err ) ) { return $err; } @@ -2491,9 +2491,8 @@ class Title { $err = $this->moveToNewTitle( $nt, $reason, $createRedirect ); $pageCountChange = ($createRedirect ? 1 : 0); } - # FIXME: moveToNewTitle() and moveOverExistingRedirect() return - # wikitext if a file move goes bad - if( is_string( $err ) ) { + + if( is_array( $err ) ) { return $err; } $redirid = $this->getArticleID(); @@ -2668,7 +2667,7 @@ class Title { $status = $file->move( $nt ); if( !$status->isOk() ) { $dbw->rollback(); - return $status->getWikiText(); + return $status->getErrorsArray(); } } } @@ -2684,6 +2683,7 @@ class Title { $u = new SquidUpdate( $urls ); $u->doUpdate(); } + } /** @@ -2761,7 +2761,7 @@ class Title { $status = $file->move( $nt ); if( !$status->isOk() ) { $dbw->rollback(); - return $status->getWikiText(); + return $status->getErrorsArray(); } } } @@ -2777,6 +2777,7 @@ class Title { # Purge old title from squid # The new title, and links to the new title, are purged in Article::onArticleCreate() $this->purgeSquid(); + } /** diff --git a/includes/api/ApiMove.php b/includes/api/ApiMove.php index 3d22cfcbdf..a3801bf873 100644 --- a/includes/api/ApiMove.php +++ b/includes/api/ApiMove.php @@ -85,10 +85,7 @@ class ApiMove extends ApiBase { if($retval !== true) { # FIXME: Title::moveTo() sometimes returns a string - if(is_array($retval)) - $this->dieUsageMsg(reset($retval)); - else - $this->dieUsageMsg(array('unknownerror', $error)); + $this->dieUsageMsg(reset($retval)); } $r = array('from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason']);