jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/371606 )

Change subject: New Wikidata Build - 2017-08-12T10:00:01+0000
......................................................................


New Wikidata Build - 2017-08-12T10:00:01+0000

Change-Id: I06b0ae94479994e3ac5905a8845608041203a35f
---
M composer.lock
M 
extensions/Wikibase/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua
M 
extensions/Wikibase/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua
M vendor/composer/installed.json
4 files changed, 56 insertions(+), 21 deletions(-)

Approvals:
  WMDE-leszek: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/composer.lock b/composer.lock
index b366fea..9b5376b 100644
--- a/composer.lock
+++ b/composer.lock
@@ -1547,12 +1547,12 @@
             "source": {
                 "type": "git",
                 "url": 
"https://github.com/wikimedia/mediawiki-extensions-Wikibase.git";,
-                "reference": "ad9c8a8671f0a5436dfc2405e56705b947a4a925"
+                "reference": "15b6e9b91f894f239199e530440304cdb53b4701"
             },
             "dist": {
                 "type": "zip",
-                "url": 
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/ad9c8a8671f0a5436dfc2405e56705b947a4a925";,
-                "reference": "ad9c8a8671f0a5436dfc2405e56705b947a4a925",
+                "url": 
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/15b6e9b91f894f239199e530440304cdb53b4701";,
+                "reference": "15b6e9b91f894f239199e530440304cdb53b4701",
                 "shasum": ""
             },
             "require": {
@@ -1629,7 +1629,7 @@
                 "wikibaserepo",
                 "wikidata"
             ],
-            "time": "2017-08-10 23:08:05"
+            "time": "2017-08-11 23:21:10"
         },
         {
             "name": "wikibase/wikimedia-badges",
diff --git 
a/extensions/Wikibase/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua
 
b/extensions/Wikibase/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua
index 112cba9..989a572 100644
--- 
a/extensions/Wikibase/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua
+++ 
b/extensions/Wikibase/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua
@@ -26,6 +26,13 @@
        RANK_DEPRECATED = 0
 }
 
+-- Is this a valid property id (Pnnn)?
+--
+-- @param {string} propertyId
+local isValidPropertyId = function( propertyId )
+       return type( propertyId ) == 'string' and propertyId:match( 
'^P[1-9]%d*$' )
+end
+
 -- Function to mask an entity's claims table in order to log access
 -- to individual claims of an entity.
 -- Code for logging based on: http://www.lua.org/pil/13.4.4.html
@@ -39,20 +46,24 @@
        entity.claims = {}
 
        local pseudoClaimsMetatable = {}
-       pseudoClaimsMetatable.__index = function( emptyTable, propertyID )
-               php.addStatementUsage(entity.id, propertyID)
-               return actualEntityClaims[propertyID]
+       pseudoClaimsMetatable.__index = function( emptyTable, propertyId )
+               if isValidPropertyId( propertyId ) then
+                       -- Only attempt to track the usage if we have a valid 
property id.
+                       php.addStatementUsage( entity.id, propertyId )
+               end
+
+               return actualEntityClaims[propertyId]
        end
 
-       pseudoClaimsMetatable.__newindex = function( emptyTable, propertyID, 
data )
+       pseudoClaimsMetatable.__newindex = function( emptyTable, propertyId, 
data )
                error( 'Entity cannot be modified' )
        end
 
-       local logNext = function( emptyTable, propertyID )
-               if propertyID ~= nil then
-                       php.addStatementUsage(entity.id, propertyID)
+       local logNext = function( emptyTable, propertyId )
+               if isValidPropertyId( propertyId ) then
+                       php.addStatementUsage( entity.id, propertyId )
                end
-               return next( actualEntityClaims, propertyID )
+               return next( actualEntityClaims, propertyId )
        end
 
        pseudoClaimsMetatable.__pairs = function( emptyTable )
@@ -187,6 +198,12 @@
 --
 -- @param {string} propertyId
 methodtable.getBestStatements = function( entity, propertyId )
+       checkType( 'getBestStatements', 1, propertyId, 'string' )
+
+       if not isValidPropertyId( propertyId ) then
+               error( 'Invalid property id passed to 
mw.wikibase.entity.getBestStatements: "' .. propertyId .. '"' )
+       end
+
        if entity.claims == nil or not entity.claims[propertyId] then
                return {}
        end
@@ -240,7 +257,7 @@
        )
 
        local label
-       if propertyLabelOrId:match( '^P%d+$' ) then
+       if isValidPropertyId( propertyLabelOrId ) then
                label = mw.wikibase.label( propertyLabelOrId )
        end
 
diff --git 
a/extensions/Wikibase/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua
 
b/extensions/Wikibase/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua
index 2c173bf..3d20045 100644
--- 
a/extensions/Wikibase/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua
+++ 
b/extensions/Wikibase/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua
@@ -211,7 +211,13 @@
 
 local function testClaimsNewIndex()
        local entity = mw.wikibase.getEntityObject( 'Q32487' )
-       entity['claims']['P321'] = ""
+       entity.claims['P321'] = ""
+end
+
+local function testClaimsAccessIndex( propertyId )
+       local entity = mw.wikibase.getEntityObject( 'Q32487' )
+
+       return entity.claims[propertyId]
 end
 
 
@@ -221,14 +227,18 @@
        { name = 'mw.wikibase.entity exists', func = testExists, 
type='ToString',
          expect = { 'table' }
        },
-       { name = 'mw.wikibase.testClaimsPairSize', func = testClaimsPairSize,
+       { name = 'mw.wikibase.entity.claims pair size', func = 
testClaimsPairSize,
          expect = { 1 }
        },
-       { name = 'mw.wikibase.testClaimsPairContent', func = 
testClaimsPairContent,
+       { name = 'mw.wikibase.entity.claims pair content', func = 
testClaimsPairContent,
          expect = { {P321={}, P4321={}}, }
        },
-       { name = 'mw.wikibase.testClaimsNewIndex', func = testClaimsNewIndex,
+       { name = 'mw.wikibase.entity.claims new index', func = 
testClaimsNewIndex,
          expect = 'Entity cannot be modified'
+       },
+       { name = 'mw.wikibase.entity.claims access invalid index', func = 
testClaimsAccessIndex,
+         args = { 'something' },
+         expect = { nil }
        },
        { name = 'mw.wikibase.entity.create with empty table', func = 
testCreate,
          args = { {} },
@@ -332,6 +342,14 @@
          args = { {} },
          expect = "bad argument #1 to 'getSitelink' (string, number or nil 
expected, got table)"
        },
+       { name = 'mw.wikibase.entity.getBestStatements bad property id 1', func 
= testGetBestStatements, type='ToString',
+         args = { function() end },
+         expect = "bad argument #1 to 'getBestStatements' (string expected, 
got function)"
+       },
+       { name = 'mw.wikibase.entity.getBestStatements bad property id 2', func 
= testGetBestStatements, type='ToString',
+         args = { 'P01' },
+         expect = 'Invalid property id passed to 
mw.wikibase.entity.getBestStatements: "P01"'
+       },
        { name = 'mw.wikibase.entity.getBestStatements 1', func = 
testGetBestStatements,
          args = { 'P321' },
          expect = { {} }
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index f46b41b..0fff612 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -1387,12 +1387,12 @@
         "source": {
             "type": "git",
             "url": 
"https://github.com/wikimedia/mediawiki-extensions-Wikibase.git";,
-            "reference": "ad9c8a8671f0a5436dfc2405e56705b947a4a925"
+            "reference": "15b6e9b91f894f239199e530440304cdb53b4701"
         },
         "dist": {
             "type": "zip",
-            "url": 
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/ad9c8a8671f0a5436dfc2405e56705b947a4a925";,
-            "reference": "ad9c8a8671f0a5436dfc2405e56705b947a4a925",
+            "url": 
"https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/15b6e9b91f894f239199e530440304cdb53b4701";,
+            "reference": "15b6e9b91f894f239199e530440304cdb53b4701",
             "shasum": ""
         },
         "require": {
@@ -1426,7 +1426,7 @@
             "jakub-onderka/php-parallel-lint": ">=0.3 <0.10",
             "wikibase/wikibase-codesniffer": "^0.1.0"
         },
-        "time": "2017-08-10 23:08:05",
+        "time": "2017-08-11 23:21:10",
         "type": "mediawiki-extension",
         "installation-source": "dist",
         "autoload": {

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I06b0ae94479994e3ac5905a8845608041203a35f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikidata
Gerrit-Branch: master
Gerrit-Owner: WikidataBuilder <wikidata-servi...@wikimedia.de>
Gerrit-Reviewer: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com>
Gerrit-Reviewer: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de>
Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de>
Gerrit-Reviewer: WMDE-leszek <leszek.mani...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to