Aude has uploaded a new change for review.

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

Change subject: Don't use multiple return values
......................................................................

Don't use multiple return values

This is a quick fix for the branch, we will probably
do something "better" on master.

Bug: T145138
Change-Id: Ib5894209f385349788846f8633df7ddd8a68bd15
(cherry picked from commit 32d61eaad2d7a84dd3c6a004e1144e59bb613c85)
---
M client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua
M client/includes/DataAccess/Scribunto/mw.wikibase.lua
M 
client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua
M client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
M docs/lua.wiki
5 files changed, 26 insertions(+), 28 deletions(-)


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

diff --git a/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua 
b/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua
index 8bce497..ac2080a 100644
--- a/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua
+++ b/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua
@@ -53,21 +53,21 @@
        langCode = langCode or mw.language.getContentLanguage():getCode()
 
        if langCode == nil then
-               return nil, nil
+               return nil
        end
 
        if entity[termType] == nil then
-               return nil, nil
+               return nil
        end
 
        local term = entity[termType][langCode]
 
        if term == nil then
-               return nil, nil
+               return nil
        end
 
        local actualLang = term.language or langCode
-       return term.value, actualLang
+       return term.value
 end
 
 -- Get the label for a given language code or the content language
diff --git a/client/includes/DataAccess/Scribunto/mw.wikibase.lua 
b/client/includes/DataAccess/Scribunto/mw.wikibase.lua
index 599f3c3..b025c71 100644
--- a/client/includes/DataAccess/Scribunto/mw.wikibase.lua
+++ b/client/includes/DataAccess/Scribunto/mw.wikibase.lua
@@ -156,7 +156,8 @@
                        return nil
                end
 
-               return php.getLabel( id )
+               local label = php.getLabel( id )
+               return label
        end
 
        -- Get the description for the given entity id, if specified, or of the
@@ -172,7 +173,8 @@
                        return nil
                end
 
-               return php.getDescription( id )
+               local description = php.getDescription( id )
+               return description
        end
 
        -- Get the local sitelink title for the given entity id.
diff --git 
a/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua
 
b/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua
index dbd88be..bc6d3dd 100644
--- 
a/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua
+++ 
b/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseEntityLibraryTests.lua
@@ -169,7 +169,7 @@
        },
        { name = 'mw.wikibase.entity.getLabel 1', func = testGetLabel, 
type='ToString',
          args = { 'de' },
-         expect = { 'LabelDE', 'de' }
+         expect = { 'LabelDE' }
        },
        { name = 'mw.wikibase.entity.getLabel 2', func = testGetLabel, 
type='ToString',
          args = { 'oooOOOOooo' },
@@ -180,15 +180,15 @@
          expect = "bad argument #1 to 'getLabel' (string, number or nil 
expected, got function)"
        },
        { name = 'mw.wikibase.entity.getLabel 4 (content language)', func = 
testGetLabel, type='ToString',
-         expect = { 'LabelDE', 'de' }
+         expect = { 'LabelDE' }
        },
        { name = 'mw.wikibase.entity.getLabel 5 (actual lang code)', func = 
testGetLabel, type='ToString',
          args = { 'en' },
-         expect = { 'LabelDE-fallback', 'de' }
+         expect = { 'LabelDE-fallback' }
        },
        { name = 'mw.wikibase.entity.getDescription 1', func = 
testGetDescription, type='ToString',
          args = { 'de' },
-         expect = { 'DescriptionDE', 'de' }
+         expect = { 'DescriptionDE' }
        },
        { name = 'mw.wikibase.entity.getDescription 2', func = 
testGetDescription, type='ToString',
          args = { 'oooOOOOooo' },
@@ -199,11 +199,11 @@
          expect = "bad argument #1 to 'getDescription' (string, number or nil 
expected, got function)"
        },
        { name = 'mw.wikibase.entity.getDescription 4 (content language)', func 
= testGetDescription, type='ToString',
-         expect = { 'DescriptionDE', 'de' }
+         expect = { 'DescriptionDE' }
        },
        { name = 'mw.wikibase.entity.getDescription 5 (actual lang code)', func 
= testGetDescription, type='ToString',
          args = { 'en' },
-         expect = { 'DescriptionDE-fallback', 'de' }
+         expect = { 'DescriptionDE-fallback' }
        },
        { name = 'mw.wikibase.entity.getSitelink 1', func = testGetSitelink, 
type='ToString',
          args = { 'ruwiki' },
@@ -243,14 +243,14 @@
        -- Integration tests
 
        { name = 'mw.wikibase.entity.getLabel integration 1', func = 
integrationTestGetLabel, type='ToString',
-         expect = { 'Lua Test Item', 'de' }
+         expect = { 'Lua Test Item' }
        },
        { name = 'mw.wikibase.entity.getLabel integration 2', func = 
integrationTestGetLabel, type='ToString',
          args = { 'en' },
-         expect = { 'Test all the code paths', 'en' }
+         expect = { 'Test all the code paths' }
        },
        { name = 'mw.wikibase.entity.getDescription integration', func = 
integrationTestGetDescription, type='ToString',
-         expect = { 'Description of Q32487', 'de' }
+         expect = { 'Description of Q32487' }
        },
        { name = 'mw.wikibase.entity.getSitelink integration 1', func = 
integrationTestGetSitelink, type='ToString',
          expect = { 'WikibaseClientDataAccessTest' }
diff --git 
a/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
 
b/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
index 2e85fea..ba5ebfa 100644
--- 
a/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
+++ 
b/client/tests/phpunit/includes/DataAccess/Scribunto/LuaWikibaseLibraryTests.lua
@@ -77,7 +77,7 @@
          expect = { nil }
        },
        { name = "mw.wikibase.getEntityObject (foreign access)", func = 
testGetEntityObjectForeignLabel,
-         expect = { 'Arbitrary access \\o/', 'de' }
+         expect = { 'Arbitrary access \\o/' }
        },
        { name = 'mw.wikibase.getEntityObject (id must be string)', func = 
mw.wikibase.getEntityObject,
          args = { 123 },
@@ -85,7 +85,7 @@
        },
        { name = 'mw.wikibase.label', func = mw.wikibase.label, type='ToString',
          args = { 'Q32487' },
-         expect = { 'Lua Test Item', 'de' }
+         expect = { 'Lua Test Item' }
        },
        { name = 'mw.wikibase.label (no such item)', func = mw.wikibase.label, 
type='ToString',
          args = { 'Q1224342342' },
@@ -93,7 +93,7 @@
        },
        { name = 'mw.wikibase.label (connected item)', func = 
mw.wikibase.label, type='ToString',
          args = {},
-         expect = { 'Lua Test Item', 'de' }
+         expect = { 'Lua Test Item' }
        },
        { name = 'mw.wikibase.label (no label)', func = mw.wikibase.label, 
type='ToString',
          args = { 'Q32488' },
@@ -101,11 +101,11 @@
        },
        { name = 'mw.wikibase.description', func = mw.wikibase.description, 
type='ToString',
          args = { 'Q32487' },
-         expect = { 'Description of Q32487', 'de' }
+         expect = { 'Description of Q32487' }
        },
        { name = 'mw.wikibase.description (connected item)', func = 
mw.wikibase.description, type='ToString',
          args = {},
-         expect = { 'Description of Q32487', 'de' }
+         expect = { 'Description of Q32487' }
        },
        { name = 'mw.wikibase.description (no such item)', func = 
mw.wikibase.description, type='ToString',
          args = { 'Q1224342342' },
diff --git a/docs/lua.wiki b/docs/lua.wiki
index aa66102..b9fa1b8 100644
--- a/docs/lua.wiki
+++ b/docs/lua.wiki
@@ -46,12 +46,11 @@
 <code>wikibase.label( id )</code><br>
 Takes an item ID and returns the label in the language of the local Wiki.
 
-If no ID was specified, then the label of the item connected to the current 
page will be returned, if the page is indeed connected and a label exists in 
the wiki's language or in a fallback language. Second return parameter is the 
language the returned label is in.
+If no ID was specified, then the label of the item connected to the current 
page will be returned, if the page is indeed connected and a label exists in 
the wiki's language or in a fallback language.
 
 An example call might look like this:
 <source lang="lua">
 mw.wikibase.label( 'Q42' ) -- Returns the label of the item as a string, like 
"Berlin".
-local label, lang = mw.wikibase.label( 'Q42' ) -- label contains the text of 
the label. lang is the language the returned label is in, like "de".
 </source>
 
 === mw.wikibase.sitelink ===
@@ -68,12 +67,11 @@
 <code>wikibase.description( id )</code><br>
 Takes an item ID and returns the description in the language of the local Wiki.
 
-If no ID was specified, then the description of the item connected to the 
current page will be returned, if the page is indeed connected and a 
description exists in the wiki's language or in a fallback language. Second 
return parameter is the language the returned description is in.
+If no ID was specified, then the description of the item connected to the 
current page will be returned, if the page is indeed connected and a 
description exists in the wiki's language or in a fallback language.
 
 An example call might look like this:
 <source lang="lua">
 mw.wikibase.description( 'Q42' ) -- Returns the description of the item as a 
string, like "capital of Germany".
-local description, lang = mw.wikibase.description( 'Q42' ) -- description 
contains the text of the description. lang is the language the returned 
description is in, like "de".
 </source>
 
 === mw.wikibase.renderSnak ===
@@ -136,23 +134,21 @@
 === mw.wikibase.entity:getLabel ===
 <code>entity:getLabel()</code><br>
 <code>entity:getLabel( langCode )</code><br>
-Returns the label of the entity in the language given as <code>langCode</code> 
or in the Wiki's content language. Second return parameter is the language the 
returned label is in.
+Returns the label of the entity in the language given as <code>langCode</code> 
or in the Wiki's content language.
 
 An example call might look like this:
 <source lang="lua">
 entity:getLabel( 'de' ) -- Returns a string, like "Berlin"
-local label, lang = entity:getLabel( 'de' ) -- label contains the text of the 
label. lang is the language the returned label is in, like "de".
 </source>
 
 === mw.wikibase.entity:getDescription ===
 <code>entity:getDescription()</code><br>
 <code>entity:getDescription( langCode )</code><br>
-Returns the description of the entity in the language given as 
<code>langCode</code> or in the Wiki's content language. Second return 
parameter is the language the returned description is in.
+Returns the description of the entity in the language given as 
<code>langCode</code> or in the Wiki's content language.
 
 An example call might look like this:
 <source lang="lua">
 entity:getDescription( 'de' ) -- Returns a string, like "capital and 
city-state of Germany"
-local desc, lang = entity:getDescription( 'de' ) -- desc contains the text of 
the description. lang is the language the returned description is in, like "de".
 </source>
 
 === mw.wikibase.entity:getSitelink ===

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5894209f385349788846f8633df7ddd8a68bd15
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: wmf/1.28.0-wmf.19
Gerrit-Owner: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: 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