Topic on Extension talk:Scribunto

attempt to index field 'text' (a nil value) in luasandbox

22
206.80.1.112 (talkcontribs)

I am using Scribunto extension and I see this error in the final pages: attempt to index field 'text' (a nil value)

When I use mw.text. Any idea why I get this error and how to fix it. This happens when I use luansandbox.

Anomie (talkcontribs)

How up-to-date is your version of Scribunto?

Toniher (talkcontribs)

I'm experiencing this error as well:

Scribunto 1_20 BRANCH (r1265) MW 1.20.3.

Anomie (talkcontribs)

Yeah, the 1_20 branch doesn't include all the latest features.

Toniher (talkcontribs)

Thanks Anomie!

In a few days I'll update wikis I'm working with Scribunto to recent 1.21 release.

Stonescri (talkcontribs)

Hi!

Did your problem go away? I'm getting the same problem with MW 1.21.1. Tried all versions of Scribunto - 1.21, 1.20, master, the one bundled with MW - same story. Thanks!

Wesleyneo (talkcontribs)

Does anyone have any leads on this problem? I have the same issue on the latest version (REL1_21) running on MediaWiki 1.21.1. Thanks.

Toniher (talkcontribs)

It was solved, yes. Sorry for the late reply.

Cuibonobo (talkcontribs)

How was this solved? I just overwrote my Scribunto extension with the latest master and I'm still experiencing this issue.

Here's the Script Error output: Lua error in Module:Namespace_detect at line 250: attempt to index field 'text' (a nil value). Backtrace: (tail call): ? Module:Namespace_detect:250: in function "chunk" mw.lua:463: in function "chunk" (tail call): ? [C]: in function "xpcall" MWServer.lua:73: in function "handleCall" MWServer.lua:266: in function "dispatch" MWServer.lua:33: in function "execute" mw_main.lua:7: in main chunk [C]: ?

And my Version output: MediaWiki 1.21.1 PHP 5.3.15 (apache2handler) MySQL 5.6.10

Rical (talkcontribs)
z = no_nil_part.nil_part is OK and then z = nil.
x = nil_part.no_nil_part give this error because a nil object can contain nothing.

To continue without error you must test the table nil_or_not :

if nil_or_not then
   x = nil_or_not.abc -- always OK
else
   -- do somethink if nil_or_not is nil. 
end

This code do the same

if nil_or_not == nil then
65.125.131.66 (talkcontribs)

Can you please tell us where/how to make that change?

15.195.201.88 (talkcontribs)

Hello, I think I can help. Go to Module:Namespace detect and edit the page. Scroll to the very bottom and find the line that says:

v = mw.text.trim(v) -- Trim whitespace.


Change this to:

--v = mw.text.trim(v) -- Trim whitespace.

This comments out the whitespace trimming. If you have a whitespace trimming fucntion you may supplement here. The reason this error is happening is that the Lua libraryies for text functions is missing. The system can't find the file, "mw.text.lua" because it does not exist.

Cuibonobo (talkcontribs)

This isn't helpful without context. Is the fix inside the Namespace_detect module or in Scribuntu? I'm afraid your answer is too generic to fix the problem.

15.195.201.88 (talkcontribs)

Hello, I think I can help. Go to Module:Namespace detect and edit the page. Scroll to the very bottom and find the line that says:

v = mw.text.trim(v) -- Trim whitespace.


Change this to:

--v = mw.text.trim(v) -- Trim whitespace.

This comments out the whitespace trimming. If you have a whitespace trimming fucntion you may supplement here. The reason this error is happening is that the Lua libraryies for text functions is missing. The system can't find the file, "mw.text.lua" because it does not exist.

Rical (talkcontribs)

You can test the table nil_or_not :

if nil_or_not then
   x = nil_or_not.abc -- always OK because nil_or_not is not nil.
else
   -- do somethink without nil_or_not which is nil
end

This if code do the same that :

if nil_or_not == nil then
178.17.20.235 (talkcontribs)

I was unable to find this code. Where/how should we do this change? Which file? Thanks! Bratza

15.195.201.88 (talkcontribs)

Hello, I think I can help. Go to Module:Namespace detect and edit the page. Scroll to the very bottom and find the line that says:

v = mw.text.trim(v) -- Trim whitespace.


Change this to:

--v = mw.text.trim(v) -- Trim whitespace.

This comments out the whitespace trimming. If you have a whitespace trimming fucntion you may supplement here. The reason this error is happening is that the Lua libraryies for text functions is missing. The system can't find the file, "mw.text.lua" because it does not exist.

Bratza (talkcontribs)

Thank you very much for your quick reply! I appreciate it!

My original thread was made here: http://www.mediawiki.org/wiki/Extension_talk:Scribunto#Template:Infobox_error_with_Scribunto_31706

Tried your advice but the Template:Infobox is still not shown correctly.

I copied the file using 'git clone' option. I was missing the file, since it was not included in the .tgz archive, when installing manually. I tried both with and without this change --v = mw.text.trim(v) -- Trim whitespace.

You can check out my original question here: http://www.mediawiki.org/wiki/Extension_talk:Scribunto#Template:Infobox_error_with_Scribunto_31706

Rical (talkcontribs)

You can test the table nil_or_not :

if nil_or_not then
   x = nil_or_not.abc -- always OK because nil_or_not is not nil.
else
   -- do somethink without nil_or_not which is nil
end

The if code do the same that :

if nil_or_not == nil then
178.17.20.235 (talkcontribs)

I was unable to find this code. Where/how should we do this change? Which file? Thanks! Bratza

Rical (talkcontribs)

You can test the table nil_or_not :

if nil_or_not then
   x = nil_or_not.abc -- always OK because nil_or_not is not nil.
else
   -- do somethink without nil_or_not which is nil
end

The if code do the same that :

if nil_or_not == nil then
DennouNeko (talkcontribs)

Well, yes. It is helpful when you want to avoid crashing the script by calling undefined function or function in udefined table, but I think that the problem here is that the mw.text doesn't seem to be implemented, as OP probably expected it to be.

I'm working with the standalone version of REL1_21 snapshot (b5015a2) on a test wiki, and the mw.text also doesn't seem to be implemented (actually couldn't find any file that would contain it).
Well, there are only few functions that I use now (basically just mw.text.trim() and mw.text.split()), so it's easy to create a temporary patch, like:

if mw.text == nil then mw.text = require("Module:MW.text") end

but it requires writing own or finding good implementations of used functions, and putting them to mentioned module.

Reply to "attempt to index field 'text' (a nil value) in luasandbox"