Hoo man has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/305655

Change subject: Change entity access parser limit report
......................................................................

Change entity access parser limit report

The new format will look like:

"entityaccesscount": {
    "value": 2,
    "limit": 250
},

which is very similar to how for example expensive functions
are reported.

Please note, that this is a breaking change. I wasn't able
to find any users of the old key, both on github or in JS
on any Wikimedia site.

Bug: T143423
Change-Id: Iba8fb025c9559a899aceacd3c6ffb5ce8d337c47
---
M client/includes/Hooks/ParserLimitReportPrepareHookHandler.php
M 
client/tests/phpunit/includes/Hooks/ParserLimitReportPrepareHookHandlerTest.php
2 files changed, 22 insertions(+), 7 deletions(-)


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

diff --git a/client/includes/Hooks/ParserLimitReportPrepareHookHandler.php 
b/client/includes/Hooks/ParserLimitReportPrepareHookHandler.php
index d0660a6..9ee5634 100644
--- a/client/includes/Hooks/ParserLimitReportPrepareHookHandler.php
+++ b/client/includes/Hooks/ParserLimitReportPrepareHookHandler.php
@@ -21,10 +21,17 @@
        private $restrictedEntityLookup;
 
        /**
-        * @param RestrictedEntityLookup $restrictedEntityLookup
+        * @var int
         */
-       public function __construct( RestrictedEntityLookup 
$restrictedEntityLookup ) {
+       private $entityAccessLimit;
+
+       /**
+        * @param RestrictedEntityLookup $restrictedEntityLookup
+        * @param int $entityAccessLimit
+        */
+       public function __construct( RestrictedEntityLookup 
$restrictedEntityLookup, $entityAccessLimit ) {
                $this->restrictedEntityLookup = $restrictedEntityLookup;
+               $this->entityAccessLimit = $entityAccessLimit;
        }
 
        /**
@@ -34,7 +41,8 @@
                $wikibaseClient = WikibaseClient::getDefaultInstance();
 
                return new self(
-                       $wikibaseClient->getRestrictedEntityLookup()
+                       $wikibaseClient->getRestrictedEntityLookup(),
+                       $wikibaseClient->getSettings()->getSetting( 
'entityAccessLimit' )
                );
        }
 
@@ -58,8 +66,11 @@
         */
        public function doParserLimitReportPrepare( Parser $parser, 
ParserOutput $output ) {
                $output->setLimitReportData(
-                       'EntityAccessCount',
-                       $this->restrictedEntityLookup->getEntityAccessCount()
+                       'limitreport-entityaccesscount',
+                       [
+                               'value' => 
$this->restrictedEntityLookup->getEntityAccessCount(),
+                               'limit' => $this->entityAccessLimit
+                       ]
                );
 
                return true;
diff --git 
a/client/tests/phpunit/includes/Hooks/ParserLimitReportPrepareHookHandlerTest.php
 
b/client/tests/phpunit/includes/Hooks/ParserLimitReportPrepareHookHandlerTest.php
index 7d28f78..6e6a04c 100644
--- 
a/client/tests/phpunit/includes/Hooks/ParserLimitReportPrepareHookHandlerTest.php
+++ 
b/client/tests/phpunit/includes/Hooks/ParserLimitReportPrepareHookHandlerTest.php
@@ -36,7 +36,8 @@
                        ->will( $this->returnValue( 42 ) );
 
                $handler = new ParserLimitReportPrepareHookHandler(
-                       $restrictedEntityLookup
+                       $restrictedEntityLookup,
+                       1234
                );
 
                $parserOutput = new ParserOutput();
@@ -45,7 +46,10 @@
 
                $limitReportData = $parserOutput->getLimitReportData();
 
-               $this->assertSame( 42, $limitReportData['EntityAccessCount'] );
+               $this->assertSame(
+                       [ 'value' => 42, 'limit' => 1234 ],
+                       $limitReportData['limitreport']['entityaccesscount']
+               );
        }
 
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iba8fb025c9559a899aceacd3c6ffb5ce8d337c47
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <h...@online.de>

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

Reply via email to