1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2025-06-06 09:24:20 +00:00

Skip invalid category titles; do not treat them as empty category titles

This commit is contained in:
gnosygnu 2016-10-18 11:16:11 -04:00
parent 2565cb9821
commit 7f4549d27a
3 changed files with 24 additions and 13 deletions

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry combineaccessrules="false" kind="src" path="/luaj-vm"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/100_core"/> <classpathentry combineaccessrules="false" exported="true" kind="src" path="/100_core"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/140_dbs"/> <classpathentry combineaccessrules="false" exported="true" kind="src" path="/140_dbs"/>

View File

@ -93,8 +93,16 @@ class Dpl_page_finder {
for (int i = 0; i < includes_len; i++) { // loop over includes for (int i = 0; i < includes_len; i++) { // loop over includes
byte[] include = (byte[])includes.Get_at(i); byte[] include = (byte[])includes.Get_at(i);
Xoa_ttl include_ttl = wiki.Ttl_parse(gplx.xowa.wikis.nss.Xow_ns_.Tid__category, include);
// pages in en.n will pass "{{{2}}}" as category title; PAGE:en.b:Category:Egypt DATE:2016-10-18
if (include_ttl == null) {
Gfo_usr_dlg_.Instance.Log_many("", "", "category title is invalid; wiki=~{0} page=~{1} ttl=~{2}", wiki.Domain_str(), itm.Page_ttl(), include);
continue; // NOTE: must ignore invalid args; EX: "{{{2}}}" is ignored but "missing_category" is not
}
cur_regy.Clear(); del_list.Clear(); cur_regy.Clear(); del_list.Clear();
Find_pages_in_ctg(cur_regy, wiki, load_mgr, itm.Page_ttl(), tmp_page, tmp_id, include); Find_pages_in_ctg(cur_regy, wiki, load_mgr, itm.Page_ttl(), tmp_page, tmp_id, include_ttl);
Del_old_pages_not_in_cur(i, tmp_id, old_regy, cur_regy, del_list); Del_old_pages_not_in_cur(i, tmp_id, old_regy, cur_regy, del_list);
Add_cur_pages_also_in_old(i, tmp_id, old_regy, cur_regy, new_regy, exclude_pages, ns_filter); Add_cur_pages_also_in_old(i, tmp_id, old_regy, cur_regy, new_regy, exclude_pages, ns_filter);
old_regy = new_regy; old_regy = new_regy;
@ -113,19 +121,13 @@ class Dpl_page_finder {
int exclude_ctgs_len = exclude_ctgs.Count(); int exclude_ctgs_len = exclude_ctgs.Count();
for (int i = 0; i < exclude_ctgs_len; i++) { for (int i = 0; i < exclude_ctgs_len; i++) {
byte[] exclude_ctg = (byte[])exclude_ctgs.Get_at(i); byte[] exclude_ctg = (byte[])exclude_ctgs.Get_at(i);
Find_pages_in_ctg(exclude_pages, wiki, load_mgr, page_ttl, tmp_page, tmp_id, exclude_ctg); Xoa_ttl exclude_ttl = wiki.Ttl_parse(gplx.xowa.wikis.nss.Xow_ns_.Tid__category, exclude_ctg);
if (exclude_ttl != null)
Find_pages_in_ctg(exclude_pages, wiki, load_mgr, page_ttl, tmp_page, tmp_id, exclude_ttl);
} }
} }
private static void Find_pages_in_ctg(Ordered_hash rv, Xowe_wiki wiki, Xodb_load_mgr load_mgr, byte[] page_ttl, Xowd_page_itm tmp_page, Int_obj_ref tmp_id, byte[] ctg_ttl) { private static void Find_pages_in_ctg(Ordered_hash rv, Xowe_wiki wiki, Xodb_load_mgr load_mgr, byte[] page_ttl, Xowd_page_itm tmp_page, Int_obj_ref tmp_id, Xoa_ttl cat_ttl) {
Xoa_ttl cat_ttl = wiki.Ttl_parse(gplx.xowa.wikis.nss.Xow_ns_.Tid__category, ctg_ttl); Xoctg_catpage_ctg ctg = wiki.Ctg__catpage_mgr().Get_or_load_or_null(page_ttl, Xoctg_catpage_url.New__blank(), cat_ttl, Int_.Max_value);
// pages in en.n will pass "{{{2}}}" as category title; DATE:2016-10-18
if (cat_ttl == null) {
Gfo_usr_dlg_.Instance.Log_many("", "", "category title is invalid; wiki=~{0} page=~{1} ttl=~{2}", wiki.Domain_str(), page_ttl, ctg_ttl);
return;
}
Xoctg_catpage_ctg ctg = wiki.Ctg__catpage_mgr().Get_or_load_or_null(page_ttl, Xoctg_catpage_url.New__blank(), cat_ttl, -1);
if (ctg == null) return; if (ctg == null) return;
// loop grps to get grp // loop grps to get grp

View File

@ -48,6 +48,16 @@ public class Dpl_xnde_tst {
); );
fxt.Test__html("No pages meet these criteria."); fxt.Test__html("No pages meet these criteria.");
} }
@Test public void Ctg_multiple_ignore_invalid() { // PURPOSE: ignore invalid category titles; PAGE:en.n:Category:Egypt DATE:2016-10-18
fxt.Init__create_ctg_pages("Ctg_0", Dpl_page_mok.new_(101, "A"));
fxt.Exec__parse
( "<DynamicPageList>"
, "category=Ctg_0"
, "category={{{2}}}" // ignore invalid titles
, "</DynamicPageList>"
);
fxt.Test__html(fxt.Make__html__itms__null("A")); // should not return nothing
}
@Test public void Notcategory() { @Test public void Notcategory() {
fxt.Init__create_ctg_pages("Ctg_0", Dpl_page_mok.new_(101, "A"), Dpl_page_mok.new_(102, "B")); fxt.Init__create_ctg_pages("Ctg_0", Dpl_page_mok.new_(101, "A"), Dpl_page_mok.new_(102, "B"));
fxt.Init__create_ctg_pages("Ctg_1", Dpl_page_mok.new_(101, "A")); fxt.Init__create_ctg_pages("Ctg_1", Dpl_page_mok.new_(101, "A"));