1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-09-28 14:30:51 +00:00

Scribunto: Fix script error 'NullPointerException' on 1 en.w page

This commit is contained in:
gnosygnu 2017-05-11 22:08:42 -04:00
parent bee71c22fe
commit ffe4c0d094
4 changed files with 16 additions and 2 deletions

View File

@ -43,6 +43,10 @@ public class Keyval_ {
int len = ary.length;
for (int i = 0; i < len; i++) {
Keyval itm = ary[i];
if (itm == null) {
sb.Add("<<NULL>>");
continue;
}
sb.Add(itm.Key()).Add("=");
Object itm_val = itm.Val();
if (Type_adp_.Eq_typeSafe(itm_val, Keyval[].class))

View File

@ -82,6 +82,10 @@ public class Scrib_proc_args {
// loop itms and handle out-of-order; note that in most cases, itms should be in-order and proc will just return rv; DATE:2016-09-12
for (int i = 0; i < rv_len; ++i) {
Keyval kv = rv[i];
// ignore null arguments; PAGE:en.w:Huadu_District DATE:2017-05-11
if (kv == null) continue;
// get integer-key; needed to handle gaps
if ( kv.Key_tid() == Type_adp_.Tid__int // luaj will be int
|| kv.Key_tid() == Type_adp_.Tid__obj) { // lua will be obj; note that luaj will also have other non-key objects

View File

@ -32,6 +32,10 @@ public class Scrib_proc_args__tst {
, Keyval_.int_(6, null), Keyval_.int_(7, null), Keyval_.int_(8, "h")
);
}
@Test public void Pull_kv_ary__null() { // PURPOSE: null arg shouldn't fail; PAGE:en.w:Huadu_District DATE:2017-05-11
fxt.Init(Keyval_.int_(1, Keyval_.Ary(Keyval_.int_(1, "a"), null, Keyval_.int_(2, "b"))));
fxt.Test__pull_kv_ary(0, Keyval_.int_(1, "a"), null, Keyval_.int_(2, "b"));
}
}
class Scrib_proc_args__fxt {
private Scrib_proc_args args;

View File

@ -15,7 +15,7 @@ Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.xtns.wbases.claims.enums; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.claims.*;
public class Wbase_claim_type_ {
public static final byte // SERIALIZED:wbase_prop|datatype
public static final byte // SERIALIZED:wbase_prop|datatype; REF:https://www.wikidata.org/wiki/Help:Data_type
Tid__unknown = 0
, Tid__value = 1
, Tid__bad = 1
@ -30,8 +30,9 @@ public class Wbase_claim_type_ {
, Tid__url = 10
, Tid__externalid = 11
, Tid__commonsmedia = 12
, Tid__geo_shape = 13
;
public static final Wbase_enum_hash Reg = new Wbase_enum_hash("claim.data_type", 13);
public static final Wbase_enum_hash Reg = new Wbase_enum_hash("claim.data_type", 14);
public static final Wbase_enum_itm
Itm__unknown = New(Tid__unknown , "unknown")
, Itm__bad = New(Tid__bad , "bad") // NOTE: wikidata identifies several entries as "bad"; Q1615351|'s-Graveland, Q107538|Baco; DATE:2013-10-20
@ -46,6 +47,7 @@ public class Wbase_claim_type_ {
, Itm__commonsmedia = New(Tid__commonsmedia , "commonsMedia") // EX:wd:Property:P14
, Itm__externalid = New(Tid__externalid , "external-id") // EX:wd:Property:P1003
, Itm__math = New(Tid__math , "math") // EX:wd:Property:P2534
, Itm__geo_shape = New(Tid__geo_shape , "geo-shape") // EX:wd:Property:P3896
;
private static Wbase_enum_itm New(byte tid, String key) {return New(tid, key, key);}
private static Wbase_enum_itm New(byte tid, String key, String scrib) {return Reg.Add(new Wbase_claim_type(tid, key, scrib));}