Merge "Exclude redirects from Special:Fewestrevisions"
[lhc/web/wiklou.git] / includes / api / ApiEditPage.php
index 8131ea5..3f63a00 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use MediaWiki\Storage\RevisionRecord;
+
 /**
  * A module that allows for editing and creating pages.
  *
@@ -52,7 +54,7 @@ class ApiEditPage extends ApiBase {
                                $oldTitle = $titleObj;
 
                                $titles = Revision::newFromTitle( $oldTitle, false, Revision::READ_LATEST )
-                                       ->getContent( Revision::FOR_THIS_USER, $user )
+                                       ->getContent( RevisionRecord::FOR_THIS_USER, $user )
                                        ->getRedirectChain();
                                // array_shift( $titles );
 
@@ -193,14 +195,14 @@ class ApiEditPage extends ApiBase {
                                $undoafterRev = Revision::newFromId( $params['undoafter'] );
                        }
                        $undoRev = Revision::newFromId( $params['undo'] );
-                       if ( is_null( $undoRev ) || $undoRev->isDeleted( Revision::DELETED_TEXT ) ) {
+                       if ( is_null( $undoRev ) || $undoRev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
                                $this->dieWithError( [ 'apierror-nosuchrevid', $params['undo'] ] );
                        }
 
                        if ( $params['undoafter'] == 0 ) {
                                $undoafterRev = $undoRev->getPrevious();
                        }
-                       if ( is_null( $undoafterRev ) || $undoafterRev->isDeleted( Revision::DELETED_TEXT ) ) {
+                       if ( is_null( $undoafterRev ) || $undoafterRev->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
                                $this->dieWithError( [ 'apierror-nosuchrevid', $params['undoafter'] ] );
                        }
 
@@ -367,21 +369,6 @@ class ApiEditPage extends ApiBase {
                $ep->importFormData( $req );
                $content = $ep->textbox1;
 
-               // Run hooks
-               // Handle APIEditBeforeSave parameters
-               $r = [];
-               // Deprecated in favour of EditFilterMergedContent
-               if ( !Hooks::run( 'APIEditBeforeSave', [ $ep, $content, &$r ], '1.28' ) ) {
-                       if ( count( $r ) ) {
-                               $r['result'] = 'Failure';
-                               $apiResult->addValue( null, $this->getModuleName(), $r );
-
-                               return;
-                       }
-
-                       $this->dieWithError( 'hookaborted' );
-               }
-
                // Do the actual save
                $oldRevId = $articleObject->getRevIdFetched();
                $result = null;
@@ -427,15 +414,15 @@ class ApiEditPage extends ApiBase {
 
                        case EditPage::AS_SUCCESS_UPDATE:
                                $r['result'] = 'Success';
-                               $r['pageid'] = intval( $titleObj->getArticleID() );
+                               $r['pageid'] = (int)$titleObj->getArticleID();
                                $r['title'] = $titleObj->getPrefixedText();
                                $r['contentmodel'] = $articleObject->getContentModel();
                                $newRevId = $articleObject->getLatest();
                                if ( $newRevId == $oldRevId ) {
                                        $r['nochange'] = true;
                                } else {
-                                       $r['oldrevid'] = intval( $oldRevId );
-                                       $r['newrevid'] = intval( $newRevId );
+                                       $r['oldrevid'] = (int)$oldRevId;
+                                       $r['newrevid'] = (int)$newRevId;
                                        $r['newtimestamp'] = wfTimestamp( TS_ISO_8601,
                                                $pageObj->getTimestamp() );
                                }