From e3ecfe45445c092b63cdfc2b01f24206afff7bfc Mon Sep 17 00:00:00 2001 From: Petr Pchelko Date: Tue, 13 Aug 2019 14:52:39 -0700 Subject: [PATCH] Check all slots in DerivedPadeDataUpdater::isCountable. 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 | 2 +- .../Storage/DerivedPageDataUpdaterTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/includes/Storage/DerivedPageDataUpdater.php b/includes/Storage/DerivedPageDataUpdater.php index 68814ef3aa..ca99a7bf0a 100644 --- a/includes/Storage/DerivedPageDataUpdater.php +++ b/includes/Storage/DerivedPageDataUpdater.php @@ -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 ); diff --git a/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php b/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php index 3b3e7416e1..2148411cbf 100644 --- a/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php +++ b/tests/phpunit/includes/Storage/DerivedPageDataUpdaterTest.php @@ -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() -- 2.20.1