Closed desb42 closed 5 years ago
in my frwiki logs there are 2271 error of this type
I have just been reviewing this issue and think the problem may be due to the wrong number of values returned by the call from lua php.getLabel( id )
mw.wikibase.lua contains the following code
-- Get the label, label language for the given entity id, if specified,
-- or of the connected entity, if exists.
--
-- @param {string} [id]
wikibase.getLabelWithLang = function( id )
checkTypeMulti( 'getLabelWithLang', 1, id, { 'string', 'nil' } )
id = getIdOfConnectedItemIfNil( id )
if id == nil then
return nil, nil
end
return php.getLabel( id )
end
As far as I can tell the function GetLabel
in 400_xowa\src\gplx\xowa\xtns\scribunto\libs\Scrib_lib_wikibase.java
is returning one value, from the above code it should be returning two.
By the same token, php.getDescription( id )
which is GetDescription
in the java file should also return two values
On yet further examination, it seems that the GetLabel code
public boolean GetLabel(Scrib_proc_args args, Scrib_proc_rslt rslt) {
Wdata_doc wdoc = Get_wdoc_or_null(args, core, "GetLabel", true);
if (wdoc == null)
return rslt.Init_ary_empty();
else
return rslt.Init_obj(wdoc.Label_list__get_or_fallback(core.Lang()));
}
should be using the wiki language not the core language My proposed change is
public boolean GetLabel(Scrib_proc_args args, Scrib_proc_rslt rslt) {
Wdata_doc wdoc = Get_wdoc_or_null(args, core, "GetLabel", true);
if (wdoc == null)
return rslt.Init_ary_empty();
else {
Xowe_wiki wiki = core.Wiki();
return rslt.Init_many_objs(wdoc.Label_list__get_or_fallback(wiki.Lang()), wiki.Lang().Key_bry());
}
}
Not sure about GetDescription
On further reflection the proposed change is not quite good enough
The function Label_list__get_or_fallback
if it should fallback, the returned result should be that language (I assume 'en')
This function needs to return two values, the text and the actual language code This could be done by changing Wdata_doc.java to return the Wdata_langtext_itm instead of just the Text()
As far as I can tell the function GetLabel in 400_xowa\src\gplx\xowa\xtns\scribunto\libs\Scrib_lib_wikibase.java is returning one value, from the above code it should be returning two.
Yeah, found the code line here: https://github.com/wikimedia/mediawiki-extensions-Wikibase/blob/6932770754e834dcc0a103221f7cc5205b5084b2/client/includes/DataAccess/Scribunto/WikibaseLanguageDependentLuaBindings.php#L73
Let me try to get it done this weekend
As far as I can tell the function GetLabel in 400_xowa\src\gplx\xowa\xtns\scribunto\libs\Scrib_lib_wikibase.java is returning one value, from the above code it should be returning two.
By the way, forgot to say it, but thanks for identifying the issue!
Pushed with the commit above. Modified 20 files because I was changing the return value (from byte[]
to Wdata_langtext_itm
) and wanted to rename the methods to catch all callers. Also did a small bit of refactoring.
Regarding your comments on language:
should be using the wiki language not the core language
Yeah, this is confusing, but they are the same. core.lang
gets seeded with wiki.lang
. I have that indirection in place because I wanted to allow for language to be changed (similar to page.lang
). It shouldn't make any difference, but let me know if I missed something
The function Label_list__get_or_fallback if it should fallback, the returned result should be that language (I assume 'en')
Poorly named method on my side. I cleaned it up a bit. But in general, the logic should be get the language for the wiki, or else, get one of its fallbacks. This is necessary for non-English languages (particularly Chinese) where the language has a fallback chain which terminates in English. For example:
en
: try en
de
: try de
first -> try en
zh-hk
: try zh-hk
first -> try zh-hans
next -> try en
This logic should work, but let me know if I'm missing something
I'm going to mark this item resolved and moving it to done. Let me know if there's anything else, otherwise will be closing out in a week or two.
Thanks!
An example of this error can be found in fr.wikipedia.org/wiki/Boels_Ladies_Tour_2016
Looking at lines 4272 - 4288
This particular error seems to be triggered by line 4279 (the comment following is interesting) A countryID of Q212 (Ukraine) causes the problem
I think this is partly to do with the fact that the language id is `UA' (not UK?)