Always return an array if an error has occurred in Title::moveTo.
This commit is contained in:
parent
88e6be8236
commit
f8a7159e6c
4 changed files with 19 additions and 16 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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']);
|
||||
|
|
|
|||
Loading…
Reference in a new issue