Check all slots in DerivedPadeDataUpdater::isCountable.
authorPetr Pchelko <ppchelko@wikimedia.org>
Tue, 13 Aug 2019 21:52:39 +0000 (14:52 -0700)
committerPetr Pchelko <ppchelko@wikimedia.org>
Fri, 16 Aug 2019 16:55:01 +0000 (09:55 -0700)
For example when the page is moved, the slots are not actually
modified, so countability of the page after the update should
not be based only on modified slots, but instead on all the page
slots.

Bug: T212706
Change-Id: Ie352ec9307b89b04af09ed85b542ca2907856bbf

includes/Storage/DerivedPageDataUpdater.php
tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php

index 68814ef..ca99a7b 100644 (file)
@@ -659,7 +659,7 @@ class DerivedPageDataUpdater implements IDBAccessObject, LoggerAwareInterface {
                        $hasLinks = (bool)count( $this->getCanonicalParserOutput()->getLinks() );
                }
 
-               foreach ( $this->getModifiedSlotRoles() as $role ) {
+               foreach ( $this->getSlots()->getSlotRoles() as $role ) {
                        $roleHandler = $this->slotRoleRegistry->getRoleHandler( $role );
                        if ( $roleHandler->supportsArticleCount() ) {
                                $content = $this->getRawContent( $role );
index 3b3e741..2148411 100644 (file)
@@ -945,6 +945,21 @@ class DerivedPageDataUpdaterTest extends MediaWikiTestCase {
                self::assertSame( $isCountable, $updater->isCountable() );
        }
 
+       /**
+        * @throws \MWException
+        * @covers \MediaWiki\Storage\DerivedPageDataUpdater::isCountable
+        */
+       public function testIsCountableNoModifiedSlots() {
+               $page = $this->getPage( __METHOD__ );
+               $content = [ 'main' => new WikitextContent( '[[Test]]' ) ];
+               $rev = $this->createRevision( $page, 'first', $content );
+               $nullRevision = MutableRevisionRecord::newFromParentRevision( $rev );
+               $nullRevision->setId( 14 );
+               $updater = $this->getDerivedPageDataUpdater( $page, $nullRevision );
+               $updater->prepareUpdate( $nullRevision );
+               $this->assertTrue( $updater->isCountable() );
+       }
+
        /**
         * @covers \MediaWiki\Storage\DerivedPageDataUpdater::doUpdates()
         * @covers \MediaWiki\Storage\DerivedPageDataUpdater::doSecondaryDataUpdates()