Merge "SearchEngine: Hard-deprecate PrefixSearch::titleSearch()"
[lhc/web/wiklou.git] / includes / Storage / DerivedPageDataUpdater.php
index 3dbe0a8..bc48a0e 100644 (file)
@@ -22,7 +22,6 @@
 
 namespace MediaWiki\Storage;
 
-use ApiStashEdit;
 use CategoryMembershipChangeJob;
 use Content;
 use ContentHandler;
@@ -38,6 +37,7 @@ use LinksDeletionUpdate;
 use LinksUpdate;
 use LogicException;
 use MediaWiki\Edit\PreparedEdit;
+use MediaWiki\MediaWikiServices;
 use MediaWiki\Revision\MutableRevisionRecord;
 use MediaWiki\Revision\RenderedRevision;
 use MediaWiki\Revision\RevisionRecord;
@@ -755,9 +755,12 @@ class DerivedPageDataUpdater implements IDBAccessObject {
 
                // TODO: MCR: allow output for all slots to be stashed.
                if ( $useStash && $slotsUpdate->isModifiedSlot( SlotRecord::MAIN ) ) {
-                       $mainContent = $slotsUpdate->getModifiedSlot( SlotRecord::MAIN )->getContent();
-                       $legacyUser = User::newFromIdentity( $user );
-                       $stashedEdit = ApiStashEdit::checkCache( $title, $mainContent, $legacyUser );
+                       $editStash = MediaWikiServices::getInstance()->getPageEditStash();
+                       $stashedEdit = $editStash->checkCache(
+                               $title,
+                               $slotsUpdate->getModifiedSlot( SlotRecord::MAIN )->getContent(),
+                               User::newFromIdentity( $user )
+                       );
                }
 
                $userPopts = ParserOptions::newFromUserAndLang( $user, $this->contLang );
@@ -1471,27 +1474,30 @@ class DerivedPageDataUpdater implements IDBAccessObject {
                        return;
                }
 
-               if ( $this->options['oldcountable'] === 'no-change' ||
-                       ( !$this->options['changed'] && !$this->options['moved'] )
-               ) {
-                       $good = 0;
-               } elseif ( $this->options['created'] ) {
-                       $good = (int)$this->isCountable();
-               } elseif ( $this->options['oldcountable'] !== null ) {
-                       $good = (int)$this->isCountable()
-                               - (int)$this->options['oldcountable'];
-               } elseif ( isset( $this->pageState['oldCountable'] ) ) {
-                       $good = (int)$this->isCountable()
-                               - (int)$this->pageState['oldCountable'];
-               } else {
-                       $good = 0;
-               }
-               $edits = $this->options['changed'] ? 1 : 0;
-               $pages = $this->options['created'] ? 1 : 0;
+               DeferredUpdates::addCallableUpdate( function () {
+                       if (
+                               $this->options['oldcountable'] === 'no-change' ||
+                               ( !$this->options['changed'] && !$this->options['moved'] )
+                       ) {
+                               $good = 0;
+                       } elseif ( $this->options['created'] ) {
+                               $good = (int)$this->isCountable();
+                       } elseif ( $this->options['oldcountable'] !== null ) {
+                               $good = (int)$this->isCountable()
+                                       - (int)$this->options['oldcountable'];
+                       } elseif ( isset( $this->pageState['oldCountable'] ) ) {
+                               $good = (int)$this->isCountable()
+                                       - (int)$this->pageState['oldCountable'];
+                       } else {
+                               $good = 0;
+                       }
+                       $edits = $this->options['changed'] ? 1 : 0;
+                       $pages = $this->options['created'] ? 1 : 0;
 
-               DeferredUpdates::addUpdate( SiteStatsUpdate::factory(
-                       [ 'edits' => $edits, 'articles' => $good, 'pages' => $pages ]
-               ) );
+                       DeferredUpdates::addUpdate( SiteStatsUpdate::factory(
+                               [ 'edits' => $edits, 'articles' => $good, 'pages' => $pages ]
+                       ) );
+               } );
 
                // TODO: make search infrastructure aware of slots!
                $mainSlot = $this->revision->getSlot( SlotRecord::MAIN );