merged from master
[lhc/web/wiklou.git] / includes / api / ApiDelete.php
index eb83432..2a6e2e7 100644 (file)
@@ -46,24 +46,11 @@ class ApiDelete extends ApiBase {
        public function execute() {
                $params = $this->extractRequestParams();
 
-               $this->requireOnlyOneParameter( $params, 'title', 'pageid' );
-
-               if ( isset( $params['title'] ) ) {
-                       $titleObj = Title::newFromText( $params['title'] );
-                       if ( !$titleObj ) {
-                               $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
-                       }
-                       $pageObj = WikiPage::factory( $titleObj );
-                       $pageObj->loadPageData( 'fromdbmaster' );
-                       if ( !$pageObj->exists() ) {
-                               $this->dieUsageMsg( 'notanarticle' );
-                       }
-               } elseif ( isset( $params['pageid'] ) ) {
-                       $pageObj = WikiPage::newFromID( $params['pageid'] );
-                       if ( !$pageObj ) {
-                               $this->dieUsageMsg( array( 'nosuchpageid', $params['pageid'] ) );
-                       }
-                       $titleObj = $pageObj->getTitle();
+               $titleObj = $this->getTitleOrPageId( $params );
+               $pageObj = WikiPage::factory( $titleObj );
+               $pageObj->loadPageData( 'fromdbmaster' );
+               if ( !$pageObj->exists() ) {
+                       $this->dieUsageMsg( 'notanarticle' );
                }
 
                $reason = ( isset( $params['reason'] ) ? $params['reason'] : null );
@@ -241,7 +228,7 @@ class ApiDelete extends ApiBase {
 
        public function getPossibleErrors() {
                return array_merge( parent::getPossibleErrors(),
-                       $this->getRequireOnlyOneParameterErrorMessages( array( 'title', 'pageid' ) ),
+                       $this->getTitleOrPageIdErrorMessage(),
                        array(
                                array( 'invalidtitle', 'title' ),
                                array( 'nosuchpageid', 'pageid' ),