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