gnosygnu / xowa

xowa offline wiki application
Other
374 stars 41 forks source link

Wikibase: Update mw.wikibase.entity for getId (and others) (Module:Infobox/Cycliste:218 attempt to call nil) #551

Closed desb42 closed 5 years ago

desb42 commented 5 years ago

While rebuilding hdump of frwiki this page fr.wikipedia.org/wiki/Fernand_Lemay gives the error

20190813_051430.317 invoke failed: Fernand_Lemay {{#invoke:Infobox|build|nom=Cycliste}}
 [err 0] <gplx> =Module:Infobox/Cycliste:218 attempt to call nil
  stack traceback:
  Module:Infobox/Cycliste:211: in function '__index'
  Module:Infobox:53: in function '__index'
  Module:Infobox:391: in function '__index'
  Module:Infobox:703: in function '__index'
  Module:Infobox:952: in function <Module:Infobox:950>
  mw.lua:531: in function <mw.lua:530>
  [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=Fernand_Lemay excerpt={{#invoke:Infobox|build|nom=Cycliste}}
  [trace]:
    gplx.xowa.xtns.scribunto.Scrib_core.Handle_error(Scrib_core.java:226)
    gplx.xowa.xtns.scribunto.engines.luaj.Luaj_engine.Dispatch_as_kv_ary(Luaj_engine.java:84)
    gplx.xowa.xtns.scribunto.engines.luaj.Luaj_engine.CallFunction(Luaj_engine.java:59)
    gplx.xowa.xtns.scribunto.Scrib_core.Invoke(Scrib_core.java:192)
    gplx.xowa.xtns.scribunto.Scrib_invoke_func.Func_evaluate(Scrib_invoke_func.java:80)
    gplx.xowa.parsers.tmpls.Xot_invk_tkn_.Eval_func(Xot_invk_tkn_.java:30)
    gplx.xowa.parsers.tmpls.Xot_invk_tkn.Tmpl_evaluate(Xot_invk_tkn.java:258)
    gplx.xowa.parsers.tmpls.Xot_defn_tmpl.Tmpl_evaluate(Xot_defn_tmpl.java:87)
    gplx.xowa.parsers.tmpls.Xot_invk_tkn.Tmpl_evaluate(Xot_invk_tkn.java:288)
    gplx.xowa.parsers.tmpls.Xot_tmpl_wtr.Write_tkn(Xot_tmpl_wtr.java:104)
    gplx.xowa.parsers.tmpls.Xot_tmpl_wtr.Write_tkn(Xot_tmpl_wtr.java:35)
    gplx.xowa.parsers.tmpls.Xot_tmpl_wtr.Write_all(Xot_tmpl_wtr.java:23)
    gplx.xowa.parsers.Xop_parser.Expand_tmpl(Xop_parser.java:50)
    gplx.xowa.parsers.Xop_parser.Expand_tmpl(Xop_parser.java:44)
    gplx.xowa.parsers.Xop_parser.Parse_text_to_wdom(Xop_parser.java:102)
    gplx.xowa.parsers.Xow_parser_mgr.Parse(Xow_parser_mgr.java:102)
    gplx.xowa.addons.bldrs.mass_parses.parses.wkrs.Xomp_parse_wkr.Exec(Xomp_parse_wkr.java:140)
    gplx.xowa.addons.bldrs.mass_parses.parses.wkrs.Xomp_parse_wkr.Invk(Xomp_parse_wkr.java:213)
    gplx.Gfo_invk_.Invk_by_msg(Gfo_invk_.java:34)
    gplx.core.threads.Thread_adp.run(Thread_adp.java:33)
    java.lang.Thread.run(Thread.java:748)

Looking at Module:Infobox/Cycliste 218 yields:

itemID=item:getId()

using dbg(mw.dump_table(item)) I can see no getId

Investigating, I came across this https://github.com/wikimedia/mediawiki-extensions-Wikibase/blob/3174995968c07d2cc64e0d9c60070650e6eefd0e/client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua

This contains some reference to getID Somehow this lua module is incorporated and applied to all wikibase objects (No idea how)

gnosygnu commented 5 years ago

Yeah, that looks like the issue. Will do this next, but am busy this weekend.

Thanks!

gnosygnu commented 5 years ago

Back from weekend, but about to dive into busy work week.

That said, I updated mw.wikibase.entity.lua to match the latest version. Tested with fr.wikipedia.org/wiki/Fernand_Lemay

Thanks again for the detailed report. Hopefully frwiki builds better now!

desb42 commented 5 years ago

just been running a build of frwiki (2019-08-01), for the mass.parse the namespaces I use are 0|4|8|12|14|100 No sign of the above issue - which is great

However, I have hit the unique constraint issue #526 again

desb42 commented 5 years ago

The unique constraint issue, in this case is of my own making I tried to fix something for enwikisource (which has unique constraint issues) and caused this problem for frwiki

I think that this issue (getId) can be closed

gnosygnu commented 5 years ago

Cool, no worries. Thanks!

desb42 commented 5 years ago

Unfortunately not.

I have just been trying to rebuild enwiki and get #invoke errors For example en.wikipedia.org/wiki/Basel

Gives method not implemented This is due to the changes in mw.wikibase.lua (and Scrib_lib_wikibase.java)

In mw.wikibase.lua are the lines

if not php.getSetting( 'allowArbitraryDataAccess' ) and entityId ~= wikibase.getEntityIdForCurrentPage() then
  error( 'Access to arbitrary entities has been disabled.', 2 )
end

The setting 'allowArbitraryDataAccess' triggers the unimplemented method

Either comment out these lines or change Scrib_lib_wikibase.java to handle the setting

gnosygnu commented 5 years ago

Ugh. Let me figure out what is the best way to handle this.

In the meantime, please do keep the lines commented out for now. Thanks.

gnosygnu commented 5 years ago

So, this was more involved than I expected. Fixed with the commit above, but the change has a bit higher risk.

More details below.

Thanks again for the follow-thru.

desb42 commented 5 years ago

Just been trying this Integrated into my version and on trying en.wikipedia.org/wiki/Kerodon I get errors of the form

Script error: @mw.wikibase.entity.lua:65 attempt to call nil

I then tried building using xowa_get_and_make.sh and this too has the same problem

On reviewing the commit I noticed that the value returned on a getSetting on fineGrainedLuaTracking has changed from false to true If in my version, I change 400_xowa\src\gplx\xowa\xtns\wbases\mediawiki\client\config\WikibaseClientDefault.java Line 44 to return false instead of true, the problem goes away

gnosygnu commented 5 years ago

Nice catch. Thanks for the break-downl

The above commit does two things:

Anyway, moving this back to done. Thanks again!