+
+ // Update article count statistics (T42009)
+ // The normal counting logic in WikiPage->doEditUpdates() is designed for
+ // one-revision-at-a-time editing, not bulk imports. In this situation it
+ // suffers from issues of slave lag. We let WikiPage handle the total page
+ // and revision count, and we implement our own custom logic for the
+ // article (content page) count.
+ $page = WikiPage::factory( $title );
+ $page->loadPageData( 'fromdbmaster' );
+ $content = $page->getContent();
+ $editInfo = $page->prepareContentForEdit( $content );
+
+ $countable = $page->isCountable( $editInfo );
+ $oldcountable = $this->countableCache['title_' . $title->getPrefixedText()];
+ if ( isset( $oldcountable ) && $countable != $oldcountable ) {
+ DeferredUpdates::addUpdate( SiteStatsUpdate::factory( array(
+ 'articles' => ( (int)$countable - (int)$oldcountable )
+ ) ) );
+ }
+