From: Bryan Tong Minh Date: Wed, 9 Jun 2010 19:52:11 +0000 (+0000) Subject: Return some more verbose error messages when editing fails using the API. Added wfDep... X-Git-Tag: 1.31.0-rc.0~36562 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=26fa8cb9f1068264eb5599ea526eb29861a7e30a;p=lhc%2Fweb%2Fwiklou.git Return some more verbose error messages when editing fails using the API. Added wfDeprecated to Article::updateArticle() and used the Status result from Article::doEdit directly in EditPage::internalAttemptSave. --- diff --git a/includes/Article.php b/includes/Article.php index af4aed40e6..6fb77fff21 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1977,6 +1977,7 @@ class Article { * @deprecated use Article::doEdit() */ function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) { + wfDeprecated( __METHOD__ ); $flags = EDIT_UPDATE | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY | ( $minor ? EDIT_MINOR : 0 ) | ( $forceBot ? EDIT_FORCE_BOT : 0 ); diff --git a/includes/EditPage.php b/includes/EditPage.php index 8830a7d9e9..33f5f50b88 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -905,6 +905,8 @@ class EditPage { $isComment = ( $this->section == 'new' ); + # FIXME: paste contents from Article::insertNewArticle here and + # actually handle errors it may return $this->mArticle->insertNewArticle( $this->textbox1, $this->summary, $this->minoredit, $this->watchthis, false, $isComment, $bot ); @@ -1051,14 +1053,20 @@ class EditPage { return self::AS_MAX_ARTICLE_SIZE_EXCEEDED; } - # update the article here - if ( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit, - $this->watchthis, $bot, $sectionanchor ) ) + // Update the article here + $flags = EDIT_UPDATE | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY | + ( $this->minoredit ? EDIT_MINOR : 0 ) | + ( $bot ? EDIT_FORCE_BOT : 0 ); + $status = $this->mArticle->doEdit( $text, $this->summary, $flags, + false, null, $this->watchthis, false, $sectionanchor, true ); + + if ( $status->isOK() ) { wfProfileOut( __METHOD__ ); return self::AS_SUCCESS_UPDATE; } else { $this->isConflict = true; + $result = $status->getErrorsArray(); } wfProfileOut( __METHOD__ ); return self::AS_END; diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index ad35b399a7..3879f75005 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -327,12 +327,13 @@ class ApiEditPage extends ApiBase { case EditPage::AS_END: // This usually means some kind of race condition - // or DB weirdness occurred. Fall through to throw an unknown - // error. - - // This needs fixing higher up, as Article::doEdit should be - // used rather than Article::updateArticle, so that specific - // error conditions can be returned + // or DB weirdness occurred. + if ( is_array( $result ) && count( $result ) > 0 ) { + $this->dieUsageMsg( array( 'unknownerror', $result[0][0] ) ); + } + + // Unknown error, but no specific error message + // Fall through default: $this->dieUsageMsg( array( 'unknownerror', $retval ) ); }