Lucas_Werkmeister_WMDE added a comment.
Some more logging, to include a full stack trace (and help me understand how
`mw.wikibase.lexeme` is even able to require `mw.wikibase` before it’s been
registered):
["log"] = table#2 {
"mw.wikibase.lexeme toplevel\
stack traceback:\
mw.wikibase.lexeme.lua:11: in main chunk\
[C]: ?",
"mw.wikibase.lexeme.setupInterface begin\
stack traceback:\
mw.wikibase.lexeme.lua:14: in function <mw.wikibase.lexeme.lua:13>\
[C]: ?",
"mw.wikibase toplevel\
stack traceback:\
mw.wikibase.lua:20: in main chunk\
[C]: ?\
[C]: in function 'loadPHPLibrary'\
mw.lua:31: in function 'loader'\
package.lua:75: in function 'load'\
package.lua:99: in function 'require'\
mw.wikibase.lexeme.lua:46: in function <mw.wikibase.lexeme.lua:13>\
[C]: ?",
"mw.wikibase.setupInterface begin\
stack traceback:\
mw.wikibase.lua:77: in function <mw.wikibase.lua:76>\
[C]: ?\
[C]: in function 'loadPHPLibrary'\
mw.lua:31: in function 'loader'\
package.lua:75: in function 'load'\
package.lua:99: in function 'require'\
mw.wikibase.lexeme.lua:46: in function <mw.wikibase.lexeme.lua:13>\
[C]: ?",
"mw.wikibase.setupInterface end\
stack traceback:\
mw.wikibase.lua:477: in function <mw.wikibase.lua:76>\
[C]: ?\
[C]: in function 'loadPHPLibrary'\
mw.lua:31: in function 'loader'\
package.lua:75: in function 'load'\
package.lua:99: in function 'require'\
mw.wikibase.lexeme.lua:46: in function <mw.wikibase.lexeme.lua:13>\
[C]: ?",
"mw.wikibase.lexeme.setupInterface end\
stack traceback:\
mw.wikibase.lexeme.lua:54: in function <mw.wikibase.lexeme.lua:13>\
[C]: ?",
"mw.wikibase toplevel\
stack traceback:\
mw.wikibase.lua:20: in main chunk\
[C]: ?",
"mw.wikibase.setupInterface begin\
stack traceback:\
mw.wikibase.lua:77: in function <mw.wikibase.lua:76>\
[C]: ?",
"mw.wikibase.setupInterface end\
stack traceback:\
mw.wikibase.lua:477: in function <mw.wikibase.lua:76>\
[C]: ?",
},
The magic happens here:
name=Scribunto_LuaEngine::load()
$this->availableLibraries = $this->getLibraries( 'lua',
self::$libraryClasses );
foreach ( $this->availableLibraries as $name => $def ) {
$this->instantiatePHPLibrary( $name, $def, false );
}
name=Scribunto_LuaEngine::loadPHPLibrary()
if ( isset( $this->availableLibraries[$name] ) ) {
$ret = $this->instantiatePHPLibrary( $name,
$this->availableLibraries[$name], true );
}
Scribunto assigns all the //available// libraries (which `getLibraries()`
gets from the `ScribuntoExternalLibraries` hook). Then it iterates through each
of them to //instantiate// the non-`deferLoad` ones, including `mw.wikibase`
and `mw.wikibase.lexeme`. But if the available libraries happen to list
`mw.wikibase.lexeme` before `mw.wikibase`, then Lexeme’s `require
'mw.wikibase'` will call `loadPHPLibrary( 'mw.wikibase' )` before `mw.wikibase`
was instantiated by the main loop in `load()`. This will instantiate
`mw.wikibase`, but then, afterwards, `load()` will reach `mw.wikibase`, and
instantiate it again. And I think that’s actually a bug in Scribunto.
You can reproduce the bug locally by adding the following to
`LocalSettings.php`:
$wgHooks['ScribuntoExternalLibraries'][] = function ( $engine,
&$extraLibraries ) {
$extraLibraries['mw.wikibase.lexeme'] = null;
$extraLibraries['mw.wikibase'] = null;
};
This hook handler will run before the “real” hook handlers in Wikibase and
WikibaseLexeme (because it’s added directly in `LocalSettings.php`, whereas the
other hook runners will only be registered when the `wfLoadExtension()` queue
is processed), so it forces the `mw.wikibase.lexeme` library to be listed
before the `mw.wikibase` one.
TASK DETAIL
https://phabricator.wikimedia.org/T294224
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Lucas_Werkmeister_WMDE
Cc: daniel, DVrandecic, Jdforrester-WMF, Lucas_Werkmeister_WMDE, Invadibot,
maantietaja, Akuckartz, Nandana, Lahi, Gq86, GoranSMilovanovic, Mahir256,
QZanden, LawExplorer, _jensen, rosalieper, Bodhisattwa, Scott_WUaS,
Wikidata-bugs, aude, Addshore, Mbch331
_______________________________________________
Wikidata-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]