1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00

Wikibase: Fix NullPointerException on a few fr.w pages [#773]

This commit is contained in:
gnosygnu 2020-08-04 07:24:52 -04:00
parent afed865c84
commit 95e833d70c
2 changed files with 107 additions and 90 deletions

View File

@ -1,6 +1,6 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
@ -13,8 +13,21 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.extensions.Wikibase.client.includes.dataAccess.scribunto; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.includes.*; import gplx.xowa.mediawiki.extensions.Wikibase.client.includes.dataAccess.*; package gplx.xowa.mediawiki.extensions.Wikibase.client.includes.dataAccess.scribunto;
import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.claims.*; import gplx.xowa.xtns.wbases.claims.itms.*; import gplx.xowa.xtns.wbases.claims.enums.*; import gplx.xowa.xtns.wbases.stores.*;
import gplx.Bry_;
import gplx.Err_;
import gplx.Gfo_usr_dlg_;
import gplx.List_adp;
import gplx.List_adp_;
import gplx.String_;
import gplx.xowa.xtns.wbases.Wdata_doc;
import gplx.xowa.xtns.wbases.Wdata_prop_val_visitor_;
import gplx.xowa.xtns.wbases.claims.Wbase_claim_grp;
import gplx.xowa.xtns.wbases.claims.enums.Wbase_claim_rank_;
import gplx.xowa.xtns.wbases.claims.itms.Wbase_claim_base;
import gplx.xowa.xtns.wbases.stores.Wbase_doc_mgr;
public class Wbase_entity_accessor { public class Wbase_entity_accessor {
private final Wbase_doc_mgr entity_mgr; private final Wbase_doc_mgr entity_mgr;
public Wbase_entity_accessor(Wbase_doc_mgr entity_mgr) { public Wbase_entity_accessor(Wbase_doc_mgr entity_mgr) {
@ -39,6 +52,7 @@ public class Wbase_entity_accessor {
Gfo_usr_dlg_.Instance.Log_many("", "", "Encountered a UnresolvedRedirectException when trying to load {0}; exc={1}", prefixedEntityId, Err_.Message_lang(ex)); Gfo_usr_dlg_.Instance.Log_many("", "", "Encountered a UnresolvedRedirectException when trying to load {0}; exc={1}", prefixedEntityId, Err_.Message_lang(ex));
return null; return null;
} }
if (entity == null) return null; // must check for null; PAGE:fr.w:Wikipédia:Ateliers_Bases/Recherche ISSUE#:773; DATE:2020-08-04
int selected_rank = ID_NULL; int selected_rank = ID_NULL;
if (Bry_.Eq(rank, RANK_BEST)) { if (Bry_.Eq(rank, RANK_BEST)) {

View File

@ -1,6 +1,6 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
@ -13,9 +13,11 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.Store; import gplx.*; import gplx.xowa.*; import gplx.xowa.mediawiki.*; import gplx.xowa.mediawiki.extensions.*; import gplx.xowa.mediawiki.extensions.Wikibase.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.*; import gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.*; package gplx.xowa.mediawiki.extensions.Wikibase.lib.includes.Store;
import gplx.xowa.xtns.wbases.core.*; import gplx.xowa.xtns.wbases.claims.*; import gplx.xowa.xtns.wbases.claims.enums.*; import gplx.xowa.xtns.wbases.claims.itms.*; import gplx.xowa.xtns.wbases.stores.*;
import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.Wdata_doc;
import gplx.xowa.xtns.wbases.stores.Wbase_doc_mgr;
public class XomwEntityRetrievingTermLookup { public class XomwEntityRetrievingTermLookup {
private final Wbase_doc_mgr entity_mgr; private final Wbase_doc_mgr entity_mgr;
public XomwEntityRetrievingTermLookup(Wbase_doc_mgr entity_mgr) { public XomwEntityRetrievingTermLookup(Wbase_doc_mgr entity_mgr) {
@ -24,6 +26,7 @@ public class XomwEntityRetrievingTermLookup {
public byte[] getLabel_or_null(byte[] entityId, byte[] languageCode) { public byte[] getLabel_or_null(byte[] entityId, byte[] languageCode) {
Wdata_doc entity = entity_mgr.Get_by_xid_or_null(entityId); Wdata_doc entity = entity_mgr.Get_by_xid_or_null(entityId);
if (entity == null) return null; // must check for null; PAGE:fr.w:Wikipédia:Ateliers_Bases/Recherche ISSUE#:773; DATE:2020-08-04
return entity.Get_label_bry_or_null(languageCode); return entity.Get_label_bry_or_null(languageCode);
} }
} }