Extension talk:Lua

Add topic
From mediawiki.org
Latest comment: 9 years ago by İncelemeelemani in topic There is not enough support for Lua

Ubuntu install not quite working[edit]

Using the 28 Dec 2008 snapshot.

The Lua50 package on my Feisty system complained about the Lua ... syntax and wouldn't run the code at all.

Hand compiled and installed Lua 5.14. Had to manually apt-get libreadline-dev to provide readline.h.

Now it runs OK, but argument passing from the Lua tag is not working under MediaWiki 1.11.1

The example program:

<lua say_hi_to="{{PAGENAME}}">
function hello(s)
  return string.format("Hello, %s!", s)

Produces: Error on line 2: bad argument #2 to 'format' (string expected, got nil)

print(hello("literal string"))

works fine.

It doesn't help to substitute a literal string into the lua tag, either.

 <lua say_hi_to="literal string">

does not work for me. -- MaxEnt 02:34, 29 December 2008 (UTC)Reply

Yes. There is either an error in the given example either in the code of the wrapper. This is due to the underscore _ in the name of the variable: if you remove these, there will be no more error. Lua could accept underscores (see Lua reference §2.1) but it should be MW which don't like it in a parser hook. ~ Seb35 14:17, 23 August 2009 (UTC)Reply

No luck on Cygwin, either[edit]

I have another wiki running on a Windows machine, version 1.12.x. I've installed both the plain Windows Lua 1.5.4 and the Cygwin binary. Both of these work fine from the command line.

Run from within MediaWiki, the Windows binary freezes up my Apache server, until I kill the stuck Lua process manually.

Got a bit further with the Cygwin version, once I ensured that the required Cygwin DLL was in my path. However, every page comes back "internal error" in big red letters.

I added some debug statements to the PHP code and determined that the wrapper is managing to construct, and the correct command is written to the Lua process, but only one line of output comes back, and this line is blank.

Working remotely, I wanted to see if the Windows Lua would get as far. Instead I managed to hose my Apache pretty good. A manual Apache stop/start cycle from the Cygwin SSH shell did not unlock the server. Running the System Internals process tools from the command line, pslist hangs with no output, and sometimes I can't even terminate the stuck pslist with ^C.

I'm sure there's a stuck Lua process causing these problems. I guess I'll have to kill it via a local VNC session tomorrow. --MaxEnt 05:57, 30 December 2008 (UTC)Reply

Is there a running Version?[edit]

I tried it under Windows, Xampp 1.7.1, MediaWiki 1.15.0 and Lua 5.1.4 (Binaries from the Binaries Page). On Command-Line Lua ist running, but in MediaWiki it crashes in busy..... Is there a running version? Christian Weiss, 23. Jun 2009 16:52 +0200

Perhaps see the first section above. Else could you give your error (what it displays). ~ Seb35 14:17, 23 August 2009 (UTC)Reply

Lua in templates[edit]

I was trying to do some templating with this extension and it didn't work (like the program in Lua following). By investigating, it was not possible to define an argument {{{who}}} because MediaWiki doesn't parse the arguments in a tag. To solve this, here is a patch.

It could be possible also to add $parser->replaceVariables($input,$frame,true) into $parser->recursiveTagParse($wgLua->wrap($input)) to replace also the template arguments in the main Lua code. But I don't know if it is desirable and not dangerous.

<lua hi="{{{who}}}">
function hello(s)
  return string.format("Hello, %s!", s)


Index: Lua.hooks.php
--- Lua.hooks.php	(révision 55524)
+++ Lua.hooks.php	(copie de travail)
@@ -13,7 +13,7 @@
 	/** ParserFirstCallInit hook */
 	public static function parserInit() {
 		global $wgParser;
-		$wgParser->setHook( 'lua', 'LuaHooks::renderTag' );
+		$wgParser->setFunctionTagHook( 'lua', 'LuaHooks::renderTag', SFH_OBJECT_ARGS );
 		$wgParser->setFunctionHook('luaexpr', 'LuaHooks::renderExpr');
 		return true;
@@ -34,7 +34,7 @@
 	/** Parser hook for the <lua> tag */
-	public static function renderTag($input, $args, &$parser) {
+	public static function renderTag(&$parser, $frame, $input, $args) {
 		global $wgLua;
 		# Create a new LuaWrapper if needed
 		if (!isset($wgLua))
@@ -45,7 +45,7 @@
 		$arglist = '';
 		foreach ($args as $key => $value)
 			$arglist .= (preg_replace('/\W/', '', $key) . '=\'' .
-				     addslashes($parser->recursiveTagParse($value)) .
+				     addslashes($parser->recursiveTagParse($parser->replaceVariables( $value, $frame, true ))) .
 		if ($arglist) {
 			try {

Lua in templates[edit]

I've tried to use this extension in the Wikipedia templates. I found it is very useful for calculating templates, but not in the templates like the infoboxes.

For instance, here is the french template fr:Modèle:DAYINYEAR365. I have modified the extension Lua to allow to include the parameters of a template in <lua>.

-- arguments
day = {{{day}}}
month = {{MONTHNUMBER|{{{month}}}}}

-- the 29th February don't exist in a non-bisxextile year
if day == 29 and month == 2 then
 -- number of years spent since the beginning of the year at the 0 of each month
 begMonth = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }

But I found it is unuseful in a infobox, since you have multiple units like {{#if:{{{location|}}}|{{!}} Location: {{!}} {{{location}}}}}.

~ Seb35 17:05, 6 September 2009 (UTC)Reply


Could someone who knows add a note on the extension page explaining whether this extension is superseded by Extension:Scribunto? Thanks. Sumana Harihareswara, Wikimedia Foundation Engineering Community Manager (talk) 18:32, 3 May 2012 (UTC)Reply

Problem in Lua Install[edit]

I have one Nursing wiki (link). I have a problem with a MediaWiki plugin in using: Lua, Scribunto, and LuaSandbox I'm having difficulty with installation. I suspect I may need to modify LocalSettings.php

Here is my current error:

internal error
[2ade0e4d] 2013-07-01 20:48:13: Fatal exception of type ScribuntoException

2: error
Lua error: Cannot create process
Media wiki Version Page: [1]

Here is a copy of my LocalSettings.php file http://persiannurse.ir/Copy/localset.txt

i have Problem in all page and template have and used #invoke: code - Example:(Template:Navbox)

i need help for install Lua From developer wikian Admin . Thanks فلورانس (talk) 22:35, 2 July 2013 (UTC)Reply


Script error: Lua error: Cannot create process: proc_open(/path/to/file.log): failed to open stream: No such file or directory

How can I solve this error?

A: You need to change /path/to/file.log to an actual available path in your LocalSettings.php file located in your wiki's root folder.

There is not enough support for Lua[edit]

I have installed at least 1,500 times MediaWiki. However, no plugin not upset me so much. I installed Ubuntu, I tried but problematic. I installed CentOS, no information on the internet regarding setup. I think this should get rid MediaWiki called lua from disease. This way is plug their head human hair. If you do not want us to use MediaWiki, you can say more clearly.--İncelemeelemani (talk) 11:20, 13 December 2014 (UTC)Reply