r67752 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67751‎ | r67752 | r67753 >
Date:19:52, 9 June 2010
Author:btongminh
Status:reverted
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/includes/api/ApiEditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -1977,6 +1977,7 @@
19781978 * @deprecated use Article::doEdit()
19791979 */
19801980 function updateArticle( $text, $summary, $minor, $watchthis, $forceBot = false, $sectionanchor = '' ) {
 1981+ wfDeprecated( __METHOD__ );
19811982 $flags = EDIT_UPDATE | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
19821983 ( $minor ? EDIT_MINOR : 0 ) |
19831984 ( $forceBot ? EDIT_FORCE_BOT : 0 );
Index: trunk/phase3/includes/EditPage.php
@@ -905,6 +905,8 @@
906906
907907 $isComment = ( $this->section == 'new' );
908908
 909+ # FIXME: paste contents from Article::insertNewArticle here and
 910+ # actually handle errors it may return
909911 $this->mArticle->insertNewArticle( $this->textbox1, $this->summary,
910912 $this->minoredit, $this->watchthis, false, $isComment, $bot );
911913
@@ -1051,14 +1053,20 @@
10521054 return self::AS_MAX_ARTICLE_SIZE_EXCEEDED;
10531055 }
10541056
1055 - # update the article here
1056 - if ( $this->mArticle->updateArticle( $text, $this->summary, $this->minoredit,
1057 - $this->watchthis, $bot, $sectionanchor ) )
 1057+ // Update the article here
 1058+ $flags = EDIT_UPDATE | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY |
 1059+ ( $this->minoredit ? EDIT_MINOR : 0 ) |
 1060+ ( $bot ? EDIT_FORCE_BOT : 0 );
 1061+ $status = $this->mArticle->doEdit( $text, $this->summary, $flags,
 1062+ false, null, $this->watchthis, false, $sectionanchor, true );
 1063+
 1064+ if ( $status->isOK() )
10581065 {
10591066 wfProfileOut( __METHOD__ );
10601067 return self::AS_SUCCESS_UPDATE;
10611068 } else {
10621069 $this->isConflict = true;
 1070+ $result = $status->getErrorsArray();
10631071 }
10641072 wfProfileOut( __METHOD__ );
10651073 return self::AS_END;
Index: trunk/phase3/includes/api/ApiEditPage.php
@@ -327,12 +327,13 @@
328328
329329 case EditPage::AS_END:
330330 // This usually means some kind of race condition
331 - // or DB weirdness occurred. Fall through to throw an unknown
332 - // error.
333 -
334 - // This needs fixing higher up, as Article::doEdit should be
335 - // used rather than Article::updateArticle, so that specific
336 - // error conditions can be returned
 331+ // or DB weirdness occurred.
 332+ if ( is_array( $result ) && count( $result ) > 0 ) {
 333+ $this->dieUsageMsg( array( 'unknownerror', $result[0][0] ) );
 334+ }
 335+
 336+ // Unknown error, but no specific error message
 337+ // Fall through
337338 default:
338339 $this->dieUsageMsg( array( 'unknownerror', $retval ) );
339340 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r70760* Revert r66878, completely misses the point of factoring out doEdit() in the...tstarling08:33, 9 August 2010

Status & tagging log