mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Mass_parse: Add separate ifexists cache
This commit is contained in:
@@ -27,38 +27,31 @@ public class Pfunc_ifexist_mgr {
|
||||
byte[] ttl_bry = ttl.Page_db(); // NOTE: must use Page_db; EX: {{#ifexist:File:Peter & Paul fortress in SPB 03.jpg|y|n}}
|
||||
|
||||
// try to get from cache
|
||||
Gfo_cache_mgr cache_mgr = wiki.Cache_mgr().Ifexist_cache();
|
||||
Pfunc_ifexist_itm cache_itm = (Pfunc_ifexist_itm)cache_mgr.Get_by_key(ttl_bry);
|
||||
if (cache_itm != null) return cache_itm.Exists();
|
||||
|
||||
cache_itm = new Pfunc_ifexist_itm(ttl_bry);
|
||||
cache_mgr.Add(ttl_bry, cache_itm, 1);
|
||||
if (wiki.Cache_mgr().Page_cache().Get_ifexist_by_mem(ttl_bry)) return true;
|
||||
db_page.Clear();
|
||||
Xow_ns ttl_ns = ttl.Ns();
|
||||
boolean rv = false;
|
||||
switch (ttl_ns.Id()) {
|
||||
case Xow_ns_.Tid__special: rv = true; break; // NOTE: some pages call for [[Special]]; always return true for now; DATE:2014-07-17
|
||||
case Xow_ns_.Tid__media: rv = Find_ttl_for_media_ns(cache_itm, wiki, ttl_ns, ttl_bry); break;
|
||||
default: rv = Find_ttl_in_db(cache_itm, wiki, ttl, ttl_ns, ttl_bry); break;
|
||||
case Xow_ns_.Tid__media: rv = Find_ttl_for_media_ns(wiki, ttl_ns, ttl_bry); break;
|
||||
default: rv = Find_ttl_in_db(wiki, ttl, ttl_ns, ttl_bry); break;
|
||||
}
|
||||
cache_itm.Exists_(rv);
|
||||
return rv;
|
||||
}
|
||||
private boolean Find_ttl_in_db(Pfunc_ifexist_itm itm, Xowe_wiki wiki, Xoa_ttl ttl, Xow_ns ns, byte[] ttl_bry) {
|
||||
boolean rv = wiki.Cache_mgr().Page_cache().Get_or_load_as_src(ttl) != null;
|
||||
private boolean Find_ttl_in_db(Xowe_wiki wiki, Xoa_ttl ttl, Xow_ns ns, byte[] ttl_bry) {
|
||||
boolean rv = wiki.Cache_mgr().Page_cache().Load_ifexist(ttl);
|
||||
if ( !rv
|
||||
&& wiki.Lang().Vnt_mgr().Enabled()) {
|
||||
Xowd_page_itm page = wiki.Lang().Vnt_mgr().Convert_mgr().Convert_ttl(wiki, ns, ttl_bry);
|
||||
if (page != Xowd_page_itm.Null)
|
||||
rv = page.Exists();
|
||||
}
|
||||
itm.Exists_(rv);
|
||||
return rv;
|
||||
}
|
||||
private boolean Find_ttl_for_media_ns(Pfunc_ifexist_itm itm, Xowe_wiki wiki, Xow_ns ns, byte[] ttl_bry) {
|
||||
private boolean Find_ttl_for_media_ns(Xowe_wiki wiki, Xow_ns ns, byte[] ttl_bry) {
|
||||
Xow_ns file_ns = wiki.Ns_mgr().Ns_file();
|
||||
Xoa_ttl file_ttl = wiki.Ttl_parse(file_ns.Id(), ttl_bry);
|
||||
boolean rv = Find_ttl_in_db(itm, wiki, file_ttl, file_ns, ttl_bry); if (rv) return true; // rarely true, but check local wiki's [[File:]] table anyway
|
||||
boolean rv = Find_ttl_in_db(wiki, file_ttl, file_ns, ttl_bry); if (rv) return true; // rarely true, but check local wiki's [[File:]] table anyway
|
||||
Xowe_wiki commons_wiki = wiki.Appe().Wiki_mgr().Wiki_commons();
|
||||
boolean env_is_testing = Env_.Mode_testing();
|
||||
if ( commons_wiki != null // null check
|
||||
@@ -67,7 +60,7 @@ public class Pfunc_ifexist_mgr {
|
||||
)
|
||||
) {
|
||||
file_ns = commons_wiki.Ns_mgr().Ns_file();
|
||||
return Find_ttl_in_db(itm, commons_wiki, file_ttl, file_ns, ttl_bry); // accurate test using page table in commons wiki (provided commons is up to date)
|
||||
return Find_ttl_in_db(commons_wiki, file_ttl, file_ns, ttl_bry); // accurate test using page table in commons wiki (provided commons is up to date)
|
||||
}
|
||||
else {
|
||||
if (!env_is_testing)
|
||||
|
||||
Reference in New Issue
Block a user