jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/382443 )
Change subject: Cleanups and minor fixes for mw.wikibase.sitelink Lua function
......................................................................
Cleanups and minor fixes for mw.wikibase.sitelink Lua function
Bug: T142903
Change-Id: I233b827b5713048fc9acd4b57c7df22823cb4e78
---
M client/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibrary.php
M
client/includes/DataAccess/Scribunto/WikibaseLanguageIndependentLuaBindings.php
M client/includes/DataAccess/Scribunto/mw.wikibase.lua
M
client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLanguageIndependentLuaBindingsTest.php
M docs/lua.wiki
5 files changed, 22 insertions(+), 22 deletions(-)
Approvals:
Hoo man: Looks good to me, approved
Lucas Werkmeister (WMDE): Looks good to me, approved
jenkins-bot: Verified
diff --git
a/client/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibrary.php
b/client/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibrary.php
index 3e4a6fe..22a5779 100644
--- a/client/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibrary.php
+++ b/client/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibrary.php
@@ -461,16 +461,16 @@
/**
* Wrapper for getSiteLinkPageName in WikibaseLuaBindings
*
- * @param string $prefixedEntityId
+ * @param string $prefixedItemId
* @param string|null $globalSiteId
*
* @return string[]
*/
- public function getSiteLinkPageName( $prefixedEntityId, $globalSiteId =
null ) {
- $this->checkType( 'getSiteLinkPageName', 1, $prefixedEntityId,
'string' );
- $this->checkTypeOptional( 'getSiteLinkPageName', 1,
$globalSiteId, 'string', null );
+ public function getSiteLinkPageName( $prefixedItemId, $globalSiteId ) {
+ $this->checkType( 'getSiteLinkPageName', 1, $prefixedItemId,
'string' );
+ $this->checkTypeOptional( 'getSiteLinkPageName', 2,
$globalSiteId, 'string', null );
- return [
$this->getLanguageIndependentLuaBindings()->getSiteLinkPageName(
$prefixedEntityId, $globalSiteId ) ];
+ return [
$this->getLanguageIndependentLuaBindings()->getSiteLinkPageName(
$prefixedItemId, $globalSiteId ) ];
}
/**
diff --git
a/client/includes/DataAccess/Scribunto/WikibaseLanguageIndependentLuaBindings.php
b/client/includes/DataAccess/Scribunto/WikibaseLanguageIndependentLuaBindings.php
index 951d01e..78295b7 100644
---
a/client/includes/DataAccess/Scribunto/WikibaseLanguageIndependentLuaBindings.php
+++
b/client/includes/DataAccess/Scribunto/WikibaseLanguageIndependentLuaBindings.php
@@ -87,16 +87,16 @@
}
/**
- * @param string $prefixedEntityId
+ * @param string $prefixedItemId
* @param string|null $globalSiteId
*
* @return string|null Null if no site link found.
*/
- public function getSiteLinkPageName( $prefixedEntityId, $globalSiteId =
null ) {
- $globalSiteId = $globalSiteId !== null ? $globalSiteId :
$this->siteId;
+ public function getSiteLinkPageName( $prefixedItemId, $globalSiteId ) {
+ $globalSiteId = $globalSiteId ?: $this->siteId;
try {
- $itemId = new ItemId( $prefixedEntityId );
+ $itemId = new ItemId( $prefixedItemId );
} catch ( InvalidArgumentException $e ) {
return null;
}
diff --git a/client/includes/DataAccess/Scribunto/mw.wikibase.lua
b/client/includes/DataAccess/Scribunto/mw.wikibase.lua
index 5aac57e..c3553c8 100644
--- a/client/includes/DataAccess/Scribunto/mw.wikibase.lua
+++ b/client/includes/DataAccess/Scribunto/mw.wikibase.lua
@@ -244,13 +244,13 @@
-- Get the local sitelink title for the given entity id.
--
- -- @param {string} id
+ -- @param {string} itemId
-- @param {string} [globalSiteId]
- wikibase.sitelink = function( id, globalSiteId )
- checkType( 'sitelink', 1, id, 'string' )
+ wikibase.sitelink = function( itemId, globalSiteId )
+ checkType( 'sitelink', 1, itemId, 'string' )
checkTypeMulti( 'sitelink', 2, globalSiteId, { 'string', 'nil'
} )
- return php.getSiteLinkPageName( id, globalSiteId )
+ return php.getSiteLinkPageName( itemId, globalSiteId )
end
diff --git
a/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLanguageIndependentLuaBindingsTest.php
b/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLanguageIndependentLuaBindingsTest.php
index 40d5703..6f12dbe 100644
---
a/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLanguageIndependentLuaBindingsTest.php
+++
b/client/tests/phpunit/includes/DataAccess/Scribunto/WikibaseLanguageIndependentLuaBindingsTest.php
@@ -50,11 +50,11 @@
$siteLinkLookup,
new SettingsArray(),
$usageAccumulator ?: new HashUsageAccumulator(),
- "enwiki" // siteId
+ 'enwiki'
);
}
- private function hasUsage( $actualUsages, EntityId $entityId, $aspect )
{
+ private function hasUsage( array $actualUsages, EntityId $entityId,
$aspect ) {
$usage = new EntityUsage( $entityId, $aspect );
$key = $usage->getIdentityString();
return isset( $actualUsages[$key] );
@@ -68,7 +68,7 @@
$this->getMock( SiteLinkLookup::class ),
$settings,
new HashUsageAccumulator(),
- "enwiki" // siteId
+ 'enwiki'
);
$this->assertSame(
@@ -119,9 +119,6 @@
/**
* @dataProvider getSiteLinkPageNameProvider
- *
- * @param string $expected
- * @param string $itemId
*/
public function testGetSiteLinkPageName( $expected, $itemId,
$globalSiteId ) {
$item = $this->getItem();
@@ -145,7 +142,7 @@
/**
* @dataProvider provideGlobalSiteId
*/
- public function testGetSiteLinkPageName_usage( $expectedUsages,
$globalSiteId ) {
+ public function testGetSiteLinkPageName_usage( array $expectedUsages,
$globalSiteId ) {
$item = $this->getItem();
$siteLinkStore = new HashSiteLinkStore();
@@ -164,6 +161,9 @@
$this->assertSame( $expectedUsages, array_keys(
$usages->getUsages() ) );
}
+ /**
+ * @return Item
+ */
private function getItem() {
$item = new Item( new ItemId( 'Q666' ) );
$item->setLabel( 'en', 'Beer' );
diff --git a/docs/lua.wiki b/docs/lua.wiki
index 6fb43b2..02ac146 100644
--- a/docs/lua.wiki
+++ b/docs/lua.wiki
@@ -72,8 +72,8 @@
</source>
=== mw.wikibase.sitelink ===
-<code>wikibase.sitelink( id )</code><br>
-<code>wikibase.sitelink( id, globalSiteId )</code><br>
+<code>wikibase.sitelink( itemId )</code><br>
+<code>wikibase.sitelink( itemId, globalSiteId )</code><br>
Takes an item ID and returns the title of the corresponding page title on the
local Wiki. This page title can be used to link to the given page.
When <code>globalSiteId</code> is given, the page title on the specified wiki
is returned, rather than the one on the local wiki.
--
To view, visit https://gerrit.wikimedia.org/r/382443
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I233b827b5713048fc9acd4b57c7df22823cb4e78
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Lucas Werkmeister (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits