[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Adds mw.wikibase.getEntityIdForTitle to Scribunto

2017-06-12 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/357126 )

Change subject: Adds mw.wikibase.getEntityIdForTitle to Scribunto
..


Adds mw.wikibase.getEntityIdForTitle to Scribunto

Allows to retrieve an item id from a page title

Simplified version of change I90699438062571887b95e05a7d13b6f295558418

Bug: T74815
Change-Id: I3ffec1f0a670f5a2e3ef072ad1a904f70149f240
---
M client/includes/DataAccess/Scribunto/mw.wikibase.lua
M client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
M docs/lua.wiki
3 files changed, 24 insertions(+), 0 deletions(-)

Approvals:
  Daniel Kinzler: Looks good to me, approved
  WMDE-leszek: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/client/includes/DataAccess/Scribunto/mw.wikibase.lua 
b/client/includes/DataAccess/Scribunto/mw.wikibase.lua
index 1577264..c709560 100644
--- a/client/includes/DataAccess/Scribunto/mw.wikibase.lua
+++ b/client/includes/DataAccess/Scribunto/mw.wikibase.lua
@@ -104,6 +104,14 @@
return pageEntityId
end
 
+   -- Get the entity id for a given page in the current wiki.
+   --
+   -- @param {string} pageTitle
+   wikibase.getEntityIdForTitle = function( pageTitle )
+   checkType( 'getEntityIdForTitle', 1, pageTitle, 'string' )
+   return php.getEntityId( pageTitle )
+   end
+
-- Get the mw.wikibase.entity object for the current page or for the
-- specified id.
--
diff --git 
a/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
 
b/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
index bd90760..4fbb1a7 100644
--- 
a/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
+++ 
b/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
@@ -71,6 +71,18 @@
{ name = 'mw.wikibase.getEntityIdForCurrentPage', func = 
mw.wikibase.getEntityIdForCurrentPage,
  expect = { 'Q32487' }
},
+   { name = 'mw.wikibase.getEntityIdForTitle with existing title', func = 
mw.wikibase.getEntityIdForTitle,
+ args = { 'WikibaseClientDataAccessTest' },
+ expect = { 'Q32487' }
+   },
+   { name = 'mw.wikibase.getEntityIdForTitle with non existing title', 
func = mw.wikibase.getEntityIdForTitle,
+ args = { 'Bar' },
+ expect = { nil }
+   },
+   { name = 'mw.wikibase.getEntityIdForTitle with invalid title', func = 
mw.wikibase.getEntityIdForTitle,
+ args = { 'a
 
+=== mw.wikibase.getEntityIdForTitle ===
+wikibase.getEntityIdForTitle( pageTitle )
+Takes a page title in the local wiki, encoded in a string, and returns the 
connected entity ID, if it exists.
+
 === mw.wikibase.getEntityUrl ===
 wikibase.getEntityUrl()
 wikibase.getEntityUrl( id )

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I3ffec1f0a670f5a2e3ef072ad1a904f70149f240
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Tpt 
Gerrit-Reviewer: Daniel Kinzler 
Gerrit-Reviewer: Hoo man 
Gerrit-Reviewer: Jackmcbarn 
Gerrit-Reviewer: Matěj Suchánek 
Gerrit-Reviewer: Petr.matas 
Gerrit-Reviewer: Thiemo Mättig (WMDE) 
Gerrit-Reviewer: Tpt 
Gerrit-Reviewer: WMDE-leszek 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Adds mw.wikibase.getEntityIdForTitle to Scribunto

2017-06-04 Thread Tpt (Code Review)
Tpt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/357126 )

Change subject: Adds mw.wikibase.getEntityIdForTitle to Scribunto
..

Adds mw.wikibase.getEntityIdForTitle to Scribunto

Allows to retrieve an item id from a page title

Simplified version of change I90699438062571887b95e05a7d13b6f295558418

Bug: T74815
Change-Id: I3ffec1f0a670f5a2e3ef072ad1a904f70149f240
---
M client/includes/DataAccess/Scribunto/mw.wikibase.lua
M client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
M docs/lua.wiki
3 files changed, 25 insertions(+), 0 deletions(-)


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

diff --git a/client/includes/DataAccess/Scribunto/mw.wikibase.lua 
b/client/includes/DataAccess/Scribunto/mw.wikibase.lua
index 1577264..429e1a9 100644
--- a/client/includes/DataAccess/Scribunto/mw.wikibase.lua
+++ b/client/includes/DataAccess/Scribunto/mw.wikibase.lua
@@ -143,6 +143,15 @@
return php.getEntityUrl( id )
end
 
+   -- Get the entity id for a given page on the current wiki.
+   --
+   -- @param {string} pageTitle
+   wikibase.getEntityIdForTitle = function( pageTitle )
+   checkType( 'getEntityIdForPage', 1, pageTitle, 'string' )
+   return php.getEntityId( pageTitle )
+   end
+
+
-- Get the label, label language for the given entity id, if specified,
-- or of the connected entity, if exists.
--
diff --git 
a/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
 
b/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
index bd90760..38ca775 100644
--- 
a/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
+++ 
b/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
@@ -97,6 +97,18 @@
  args = { 123 },
  expect = "bad argument #1 to 'getEntity' (string or nil expected, got 
number)"
},
+   { name = 'mw.wikibase.getEntityIdForTitle with existing title', func = 
mw.wikibase.getEntityIdForTitle,
+ args = { 'FooBarFoo' },
+ expect = { 'Q32487' }
+   },
+   { name = 'mw.wikibase.getEntityIdForTitle with non existing title', 
func = mw.wikibase.getEntityIdForTitle,
+ args = { 'Bar' },
+ expect = { nil }
+   },
+   { name = 'mw.wikibase.getEntityIdForTitle with invalid title', func = 
mw.wikibase.getEntityIdForTitle,
+   args = { 'ahttp://wikidata.org/wiki/Q42";.
 
 
+=== mw.wikibase.getEntityIdForTitle ===
+wikibase.getEntityIdForPage( pageTitle )
+Takes a page title in the local wiki and returns the entity id in the 
repository.
+
 === mw.wikibase.label ===
 wikibase.label()
 wikibase.label( id )

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ffec1f0a670f5a2e3ef072ad1a904f70149f240
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Tpt 

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