gnosygnu / xowa

xowa offline wiki application
Other
374 stars 41 forks source link

Wikibase: Synchronize latest mw.wikibase.entity.lua (Module:Wd:162 attempt to call nil) #614

Closed desb42 closed 4 years ago

desb42 commented 4 years ago

I am building a few wikis from the 2019-11-01 dumps This error occurs when I try to build (hdump) enwiki - the full trace is

invoke failed: Alabama {{safesubst:#invoke:Wd|main}}
 [err 0] <gplx> =Module:Wd:162 attempt to call nil
  stack traceback:
    Module:Wd:122: in function '__index'
    Module:Wd:2156: in function <Module:Wd:2155>
    mw.lua:535: in function <mw.lua:534>
   [Java]: in function '__index'  g:/xowa/bin/any/xowa/xtns/Scribunto/engines/Luaj/MWServer.lua:75:
    in function <g:/xowa/bin/any/xowa/xtns/Scribunto/engines/Luaj/MWServer.lua:74>
   [Java]: in ?: ttl=Alabama excerpt={{safesubst:#invoke:Wd|main}} [trace]:
      gplx.xowa.xtns.scribunto.Scrib_core.Handle_error(Unknown Source)
      gplx.xowa.xtns.scribunto.engines.luaj.Luaj_engine.Dispatch_as_kv_ary(Unknown Source)
      gplx.xowa.xtns.scribunto.engines.luaj.Luaj_engine.CallFunction(Unknown Source)
      gplx.xowa.xtns.scribunto.Scrib_core.Invoke(Unknown Source)
      gplx.xowa.xtns.scribunto.Scrib_invoke_func.Func_evaluate(Unknown Source)
      gplx.xowa.parsers.tmpls.Xot_invk_tkn_.Eval_func(Unknown Source)
      gplx.xowa.parsers.tmpls.Xot_invk_tkn.Tmpl_evaluate(Unknown Source)
      gplx.xowa.parsers.tmpls.Xot_defn_tmpl.Tmpl_evaluate(Unknown Source)
      gplx.xowa.parsers.tmpls.Xot_invk_tkn.Tmpl_evaluate(Unknown Source)
      gplx.xowa.parsers.tmpls.Arg_itm_tkn_base.Tmpl_evaluate(Unknown Source)
      gplx.xowa.parsers.tmpls.Arg_nde_tkn.Tmpl_evaluate(Unknown Source)
      gplx.xowa.parsers.tmpls.Xot_invk_tkn.Tmpl_evaluate(Unknown Source)
      gplx.xowa.parsers.tmpls.Xot_defn_tmpl.Tmpl_evaluate(Unknown Source)
      gplx.xowa.parsers.tmpls.Xot_invk_tkn.Tmpl_evaluate(Unknown Source)
      gplx.xowa.parsers.tmpls.Xot_tmpl_wtr.Write_tkn(Unknown Source)
      gplx.xowa.parsers.tmpls.Xot_tmpl_wtr.Write_tkn(Unknown Source)
      gplx.xowa.parsers.tmpls.Xot_tmpl_wtr.Write_all(Unknown Source)
      gplx.xowa.parsers.Xop_parser.Expand_tmpl(Unknown Source)
      gplx.xowa.parsers.Xop_parser.Expand_tmpl(Unknown Source)
      gplx.xowa.parsers.Xop_parser.Parse_text_to_wdom(Unknown Source)
      gplx.xowa.parsers.Xow_parser_mgr.Parse(Unknown Source)
      gplx.xowa.addons.bldrs.mass_parses.parses.wkrs.Xomp_parse_wkr.Exec(Unknown Source)
      gplx.xowa.addons.bldrs.mass_parses.parses.wkrs.Xomp_parse_wkr.Invk(Unknown Source)
      gplx.Gfo_invk_.Invk_by_msg(Unknown Source)
      gplx.core.threads.Thread_adp.run(Unknown Source)
      java.lang.Thread.run(Thread.java:748)

I am using a build of xowa from commit 8653e665cc83e936c4152446e6763d8b5f0aadc1

If I run xowa-gui or xowa-http the page Alabama appears (with no error) My suspicion is that there is a subtly different startup for the hdump process For this exercise I am only using one worker (so as not to get into any multithread issues)

Line 162 of Module:Wd reads

cfg.langObj = mw.language.new(cfg.langCode)

however, I cannot see why this is an issue

desb42 commented 4 years ago

Turns out, I was off by one The line in question is the following line

cfg.siteID = mw.wikibase.getGlobalSiteId()

getGlobalSiteId does not exist in xowa (sort of) It's a very recent addition to mw.wikibase.lua (or at least rearrangement)

Confusingly getGlobalSiteId exists in mw.wikibase.entity.lua - and is probably why this works for xowa-gui

but when running hdump (on enwiki 2019-11-01) a few more lines in mw.wikibase.lua seems to do the trick The lines are:

function wikibase.getGlobalSiteId()
  return php.getGlobalSiteId()
end

with another change to Scrib_lib_wikibase.java to expose the getGlobalSiteId() function

gnosygnu commented 4 years ago

Thanks for the breakdown as well as the pointers.

I synchronized mw.wikibase.entity.lua and added support for the underlying functions. Tested against the latest 2019-11 en.w Alabama

Let me know if anything else. Thanks!

desb42 commented 4 years ago

In the change that I made - calling php.getGlobalSiteId() directly instead of calling php.getSetting( 'siteGlobalID' )

getGlobalSiteId within xowa calls core.Wiki().Domain_abrv() which for this wiki I believe is enwiki

As far as I can tell using php.getSetting( 'siteGlobalID' ), this will always return wikidatawiki

gnosygnu commented 4 years ago

Nice catch! I incorrectly assumed that the getSettings call was the same for all wikis.

Fixed in the commit above. Reference urls below.

Thanks!