Merge "Add .pipeline/ with dev image variant"
[lhc/web/wiklou.git] / includes / api / ApiEditPage.php
index e631e3f..1936407 100644 (file)
@@ -20,7 +20,8 @@
  * @file
  */
 
-use MediaWiki\Storage\RevisionRecord;
+use MediaWiki\MediaWikiServices;
+use MediaWiki\Revision\RevisionRecord;
 
 /**
  * A module that allows for editing and creating pages.
@@ -239,11 +240,15 @@ class ApiEditPage extends ApiBase {
                        $params['text'] = $newContent->serialize( $contentFormat );
                        // If no summary was given and we only undid one rev,
                        // use an autosummary
-                       if ( is_null( $params['summary'] ) &&
-                               $titleObj->getNextRevisionID( $undoafterRev->getId() ) == $params['undo']
-                       ) {
-                               $params['summary'] = wfMessage( 'undo-summary' )
-                                       ->params( $params['undo'], $undoRev->getUserText() )->inContentLanguage()->text();
+
+                       if ( is_null( $params['summary'] ) ) {
+                               $nextRev = MediaWikiServices::getInstance()->getRevisionLookup()
+                                       ->getNextRevision( $undoafterRev->getRevisionRecord() );
+                               if ( $nextRev && $nextRev->getId() == $params['undo'] ) {
+                                       $params['summary'] = wfMessage( 'undo-summary' )
+                                               ->params( $params['undo'], $undoRev->getUserText() )
+                                               ->inContentLanguage()->text();
+                               }
                        }
                }
 
@@ -378,6 +383,7 @@ class ApiEditPage extends ApiBase {
                $status = $ep->attemptSave( $result );
                $wgRequest = $oldRequest;
 
+               $r = [];
                switch ( $status->value ) {
                        case EditPage::AS_HOOK_ERROR:
                        case EditPage::AS_HOOK_ERROR_EXPECTED: