X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiEditPage.php;h=8ad2ad9383ce328cf9bf6a307343b0e82f564c89;hb=4b8b0358ebca88abe8aa933becc5fd917d1799f4;hp=c1598c8073634e1605dab5c68c8877523b4a6cde;hpb=aa04aab5cf9649b3ce17a83db40af8737a77cc41;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index c1598c8073..8ad2ad9383 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -195,9 +195,9 @@ class ApiEditPage extends ApiBase { list( $params['undo'], $params['undoafter'] ) = array( $params['undoafter'], $params['undo'] ); } - $undoafterRev = Revision::newFromID( $params['undoafter'] ); + $undoafterRev = Revision::newFromId( $params['undoafter'] ); } - $undoRev = Revision::newFromID( $params['undo'] ); + $undoRev = Revision::newFromId( $params['undo'] ); if ( is_null( $undoRev ) || $undoRev->isDeleted( Revision::DELETED_TEXT ) ) { $this->dieUsageMsg( array( 'nosuchrevid', $params['undo'] ) ); } @@ -252,8 +252,9 @@ class ApiEditPage extends ApiBase { 'format' => $contentFormat, 'model' => $contentHandler->getModelID(), 'wpEditToken' => $params['token'], - 'wpIgnoreBlankSummary' => '', - 'wpIgnoreBlankArticle' => true + 'wpIgnoreBlankSummary' => true, + 'wpIgnoreBlankArticle' => true, + 'wpIgnoreSelfRedirect' => true, ); if ( !is_null( $params['summary'] ) ) { @@ -381,7 +382,7 @@ class ApiEditPage extends ApiBase { // Run hooks // Handle APIEditBeforeSave parameters $r = array(); - if ( !wfRunHooks( 'APIEditBeforeSave', array( $ep, $content, &$r ) ) ) { + if ( !Hooks::run( 'APIEditBeforeSave', array( $ep, $content, &$r ) ) ) { if ( count( $r ) ) { $r['result'] = 'Failure'; $apiResult->addValue( null, $this->getModuleName(), $r ); @@ -406,7 +407,14 @@ class ApiEditPage extends ApiBase { switch ( $status->value ) { case EditPage::AS_HOOK_ERROR: case EditPage::AS_HOOK_ERROR_EXPECTED: - $this->dieUsageMsg( 'hookaborted' ); + if ( isset( $status->apiHookResult ) ) { + $r = $status->apiHookResult; + $r['result'] = 'Failure'; + $apiResult->addValue( null, $this->getModuleName(), $r ); + return; + } else { + $this->dieUsageMsg( 'hookaborted' ); + } case EditPage::AS_PARSE_ERROR: $this->dieUsage( $status->getMessage(), 'parseerror' ); @@ -454,7 +462,6 @@ class ApiEditPage extends ApiBase { case EditPage::AS_CONFLICT_DETECTED: $this->dieUsageMsg( 'editconflict' ); - // case EditPage::AS_SUMMARY_NEEDED: Can't happen since we set wpIgnoreBlankSummary case EditPage::AS_TEXTBOX_EMPTY: $this->dieUsageMsg( 'emptynewsection' ); @@ -479,6 +486,7 @@ class ApiEditPage extends ApiBase { break; case EditPage::AS_SUMMARY_NEEDED: + // Shouldn't happen since we set wpIgnoreBlankSummary, but just in case $this->dieUsageMsg( 'summaryrequired' ); case EditPage::AS_END: