Topic on Extension talk:Scribunto

Lua error in Module:Citation/CS1/Configuration at line 2058: attempt to index a boolean value.

6
Rothwell4217 (talkcontribs)

Hello. I imported w:Template:Cite book to my wiki but when I tried to use it I got:

Lua error in Module:Citation/CS1/Configuration at line 2058: attempt to index a boolean value.

Backtrace:

Module:Citation/CS1/Configuration:2058: in function "init"
package.lua:103: ?
(tail call): ?
mw.lua:496: in function "executeModule"
mw.lua:768: in function "loadData"
Module:Citation/CS1:4394: in function "chunk"
mw.lua:527: ?
[C]: ?

Here are lines 2048-2060:

--[[--------------------------< I D _ L I M I T S _ D A T A _ T >----------------------------------------------

fetch id limits for certain identifiers from c:Data:CS1/Identifier limits.tab.  This source is a json tabular 
data file maintained at wikipedia commons.  Convert the json format to a table of k/v pairs.

The values from <id_limits_data_t> are used to set handle.id_limit.

]]

local id_limits_data_t = {};
for _, limit_t in ipairs (mw.ext.data.get ("CS1/Identifier limits.tab").data) do
	id_limits_data_t[limit_t[1]] = limit_t[2];									-- <limit[1]> is identifier; <limit[2]> is upper limit for that identifier
end

Line 2058 is:

for _, limit_t in ipairs (mw.ext.data.get ("CS1/Identifier limits.tab").data) do

I'm guessing it's something to do with it not being able to pull the data from c:Data:Cs1/Identifier limits.tab. But I'm not really sure how to fix it?

FeRDNYC (talkcontribs)

It's actually at c:Data:CS1/Identifier limits.tab (note the capital "S"), and that page does exist... however, it's possible your wiki isn't configured for the same interwiki access that MediaWiki modules would have automatically enabled. (That's a guess, but it seems likely as you'll note the identifier in the source is simply "CS1/Identifier limits.tab" — how would the code know to access that data from https://commons.wikimedia.org/wiki/Data:CS1/Identifier_limits.tab, when it's running on your wiki?)

The data page was only created in January, the discussion about is at w:Help talk:Citation Style 1/Archive 93#Limits. I'm not sure if anyone considered the implications for importing the modules to other wikis. The edit that added its use is this one. Prior to that change, the values were simply hardcoded into the module. Trappist the monk might have some insights into the external-wiki issues with the data import, and how/if your wiki can access the data directly from Commons.

The simplest solution might be to just edit the module to re-hardcode the values. Or, you could try importing the data page into your wiki, if you're set up for a Data namespace and the Tabular.JsonConfig content model, and changing the code to load the data locally from your newly-imported page.

Trappist the monk (talkcontribs)

The lua documentation for fetching tabular data is at en:mw:Extension:Scribunto/Lua_reference_manual#mw.ext.data. There are links to more information about tabular data there. I doubt that making a local copy will work because I suspect that the mw.ext.data() function is hard-coded to look for the data in the Data namespace at commons.

FeRDNYC (talkcontribs)

Shockingly enough (at least to me), mw.ext.data is the thinnest of wrappers around JsonConfig's PHP code. Any call to mw.ext.data.get() is essentially invoking the JCLuaLibrary.php public function get.

The salient points here are probably that:

  1. The entirety of mw.ext.data is supplied by the JsonConfig extension, not by Scribunto.
  2. From the error message displayed, it's not clear whether JsonConfig is installed on the wiki in question. (I don't see any sign the mw.ext.data.get function itself is being executed.)
  3. If JsonConfig isn't installed, that'd definitely break things.
  4. (If it is, it may just need to be configured.)
FeRDNYC (talkcontribs)

(None of this changes the fact that re-hardcoding the data — essentially undoing the parts of Trappist's edit that add the lookup code, or replace numbers with data from the external table — is still a viable option for solving this without having to install an entire other extension to the wiki.)

Tacsipacsi (talkcontribs)

From the error message displayed, it's not clear whether JsonConfig is installed on the wiki in question. (I don't see any sign the mw.ext.data.get function itself is being executed.)

I think if the function wasn’t installed, it resulted in a nil somewhere, not a boolean value. JCLuaLibrary::get(), on the other hand, seems to indeed return false if the content is not found. So probably JsonConfig is installed, but not properly configured.

I doubt that making a local copy will work because I suspect that the mw.ext.data() function is hard-coded to look for the data in the Data namespace at commons.

The problem is exactly that it isn’t hardcoded to use Commons. See Extension:JsonConfig#Supporting Wikimedia templates for how to configure it to use Commons.

Reply to "Lua error in Module:Citation/CS1/Configuration at line 2058: attempt to index a boolean value."