Thiemo Mättig (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/378228 )

Change subject: Clean up unused code, comments and docs in WikiPageUpdaterTest
......................................................................

Clean up unused code, comments and docs in WikiPageUpdaterTest

This is a follow up for all the comments I wrote on Ic095e2e, see there.

The 300 is the default from core's $wgUpdateRowsPerJob setting.

Bug: T174422
Change-Id: Iac335ca28f8672b45f8a65b4b590b486a7138421
---
M client/includes/Changes/WikiPageUpdater.php
M client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
M docs/options.wiki
3 files changed, 16 insertions(+), 43 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/28/378228/1

diff --git a/client/includes/Changes/WikiPageUpdater.php 
b/client/includes/Changes/WikiPageUpdater.php
index 6d0081e..e3774c7 100644
--- a/client/includes/Changes/WikiPageUpdater.php
+++ b/client/includes/Changes/WikiPageUpdater.php
@@ -41,12 +41,12 @@
        /**
         * @var int Batch size for UpdateHtmlCacheJob
         */
-       private $purgeCacheBatchSize = 100;
+       private $purgeCacheBatchSize = 300;
 
        /**
         * @var int Batch size for InjectRCRecordsJob
         */
-       private $rcBatchSize = 100;
+       private $rcBatchSize = 300;
 
        /**
         * @var RecentChangesDuplicateDetector|null
@@ -107,6 +107,10 @@
                $this->rcBatchSize = $rcBatchSize;
        }
 
+       /**
+        * @param string $updateType
+        * @param int $delta
+        */
        private function incrementStats( $updateType, $delta ) {
                if ( $this->stats ) {
                        $this->stats->updateCount( 
'wikibase.client.pageupdates.' . $updateType, $delta );
@@ -149,7 +153,7 @@
                }
 
                $jobs = [];
-               $titleBatches = array_chunk( $titles, 
$this->getPurgeCacheBatchSize() );
+               $titleBatches = array_chunk( $titles, 
$this->purgeCacheBatchSize );
 
                /* @var Title[] $batch */
                foreach ( $titleBatches as $batch ) {
@@ -182,13 +186,10 @@
                        return;
                }
 
-               $c = 0;
-
                // NOTE: no batching here, since RefreshLinksJobs are slow, and 
benefit more from
                // deduplication and checking against page_touched than from 
reducing overhead
                // through batching.
 
-               /* @var Title $title */
                foreach ( $titles as $title ) {
                        $job = new RefreshLinksJob(
                                $title, // the title will be ignored because 
the 'pages' parameter is set.
@@ -196,10 +197,9 @@
                        );
 
                        $this->jobQueueGroup->lazyPush( $job );
-                       $c++;
                }
 
-               $this->incrementStats( 'RefreshLinks.jobs', $c );
+               $this->incrementStats( 'RefreshLinks.jobs', count( $titles ) );
                $this->incrementStats( 'RefreshLinks.titles', count( $titles ) 
);
        }
 
diff --git a/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php 
b/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
index 82b2021..9b8f538 100644
--- a/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
+++ b/client/tests/phpunit/includes/Changes/WikiPageUpdaterTest.php
@@ -71,9 +71,9 @@
         * @param string $text
         * @param int $id
         *
-        * @return Title|PHPUnit_Framework_MockObject_MockObject
+        * @return Title
         */
-       private function getTitleMock( $text, $id = 23 ) {
+       private function getTitleMock( $text, $id ) {
                $title = $this->getMockBuilder( Title::class )
                        ->disableOriginalConstructor()
                        ->getMock();
@@ -110,31 +110,6 @@
        }
 
        /**
-        * @param int $id
-        *
-        * @return PHPUnit_Framework_MockObject_MockObject|EntityChange
-        */
-       private function getEntityChangeMock( $id = 77 ) {
-               $change = $this->getMockBuilder( EntityChange::class )
-                       ->disableOriginalConstructor()
-                       ->getMock();
-
-               $change->expects( $this->any() )
-                       ->method( 'getId' )
-                       ->will( $this->returnValue( $id ) );
-
-               $change->expects( $this->any() )
-                       ->method( 'getFields' )
-                       ->will( $this->returnValue( [ 'id' => $id, 'info' => [] 
] ) );
-
-               $change->expects( $this->any() )
-                       ->method( 'getSerializedInfo' )
-                       ->will( $this->returnValue( '{}' ) );
-
-               return $change;
-       }
-
-       /**
         * @return LBFactory
         */
        private function getLBFactoryMock() {
@@ -157,7 +132,7 @@
                $jobQueueGroup->expects( $this->atLeastOnce() )
                        ->method( 'lazyPush' )
                        ->will( $this->returnCallback( function( array $jobs ) 
use ( &$pages, &$rootJobParams ) {
-                               /** @var Job $job */
+                               /** @var Job[] $jobs */
                                foreach ( $jobs as $job ) {
                                        $this->assertInstanceOf( 
HTMLCacheUpdateJob::class, $job );
                                        $params = $job->getParams();
@@ -250,8 +225,6 @@
                $titleBar = $this->getTitleMock( 'Bar', 22 );
                $titleCuzz = $this->getTitleMock( 'Cuzz', 23 );
 
-               $change = $this->getEntityChangeMock();
-
                $jobQueueGroup = $this->getJobQueueGroupMock();
 
                $pages = [];
@@ -259,8 +232,8 @@
                $jobQueueGroup->expects( $this->atLeastOnce() )
                        ->method( 'lazyPush' )
                        ->will( $this->returnCallback(
-                               function( array $jobs ) use ( &$pages, $change, 
&$rootJobParams ) {
-                                       /** @var Job $job */
+                               function ( array $jobs ) use ( &$pages, 
&$rootJobParams ) {
+                                       /** @var Job[] $jobs */
                                        foreach ( $jobs as $job ) {
                                                $this->assertSame( 
'wikibase-InjectRCRecords', $job->getType() );
                                                $params = $job->getParams();
@@ -280,7 +253,7 @@
 
                $updater->injectRCRecords(
                        [ $titleFoo, $titleBar, $titleCuzz, ],
-                       $change,
+                       new EntityChange(),
                        [ 'rootJobTimestamp' => '20202211060708', 
'rootJobSignature' => 'Kittens!', ]
                );
 
diff --git a/docs/options.wiki b/docs/options.wiki
index 5e29487..dbd7605 100644
--- a/docs/options.wiki
+++ b/docs/options.wiki
@@ -112,5 +112,5 @@
 ;echoIcon: If <code>sendEchoNotification</code> is set to <code>true</code>, 
you can also provide what icon the user will see. The correct syntax is <code>[ 
'url' => '...' ]</code> or <code>[ 'path' => '...' ]</code> where 
<code>path</code> is relative to <code>$wgExtensionAssetsPath</code>. Defaults 
to <code>false</code> which means that there will be the default Echo icon.
 ;disabledUsageAspects: Array of usage aspects that should not be saved in the 
<code>wbc_entity_usage</code> table. This currently only supports aspect codes 
(like "T", "L" or "X"), but not full aspect keys (like "L.de").
 ;wikiPageUpdaterDbBatchSize: DEPRECATED. If set, acts as a default for 
purgeCacheBatchSize and recentChangesBatchSize.
-;purgeCacheBatchSize: Number o pages to process in each UpdateHtmlCacheJob, 
defaults to $wgUpdateRowsPerJob (after wikiPageUpdaterDbBatchSize, for 
backwards compatibility).
-;recentChangesBatchSize: Batch size for database operations in 
InjectRCRecordsJob, defaults to $wgUpdateRowsPerJob (after 
wikiPageUpdaterDbBatchSize, for backwards compatibility).
+;purgeCacheBatchSize: Number of pages to process in each UpdateHtmlCacheJob. 
Defaults to wikiPageUpdaterDbBatchSize (for backwards compatibility) or 
MediaWiki core's $wgUpdateRowsPerJob (which defaults to 300).
+;recentChangesBatchSize: Batch size for database operations in 
InjectRCRecordsJob. Defaults to wikiPageUpdaterDbBatchSize (for backwards 
compatibility) or MediaWiki core's $wgUpdateRowsPerJob (which defaults to 300).

-- 
To view, visit https://gerrit.wikimedia.org/r/378228
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iac335ca28f8672b45f8a65b4b590b486a7138421
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to