From: Petr Pchelko Date: Tue, 13 Aug 2019 21:52:39 +0000 (-0700) Subject: Check all slots in DerivedPadeDataUpdater::isCountable. X-Git-Tag: 1.34.0-rc.0~699 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=commitdiff_plain;h=e3ecfe45445c092b63cdfc2b01f24206afff7bfc;p=lhc%2Fweb%2Fwiklou.git 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 --- 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()