https://www.mediawiki.org/wiki/Special:Code/MediaWiki/110082

Revision: 110082
Author:   reedy
Date:     2012-01-26 21:01:11 +0000 (Thu, 26 Jan 2012)
Log Message:
-----------
Fix register_globals

lowercase bools

Modified Paths:
--------------
    trunk/extensions/Lua/Lua.hooks.php
    trunk/extensions/Lua/Lua.php
    trunk/extensions/Lua/Lua.wrapper.php

Modified: trunk/extensions/Lua/Lua.hooks.php
===================================================================
--- trunk/extensions/Lua/Lua.hooks.php  2012-01-26 20:59:58 UTC (rev 110081)
+++ trunk/extensions/Lua/Lua.hooks.php  2012-01-26 21:01:11 UTC (rev 110082)
@@ -9,7 +9,11 @@
  */
 
 class LuaHooks {
-       /** ParserFirstCallInit hook */
+       /**
+        * ParserFirstCallInit hook
+        * @param $parser Parser
+        * @return bool
+        */
        public static function parserInit( &$parser ) {
                $parser->setHook( 'lua', 'LuaHooks::renderTag' );
                $parser->setFunctionHook('luaexpr', 'LuaHooks::renderExpr');
@@ -19,19 +23,26 @@
        /** ParserBeforeTidy hook */
        public static function beforeTidy(&$parser, &$text) {
                global $wgLua;
-               if (isset($wgLua)) {
+               if ( $wgLua !== null ) {
                        $wgLua->destroy();
                }
-               return TRUE;
+               return true;
        }
 
-       /** Parser hook for the <lua> tag */
+       /**
+        * Parser hook for the <lua> tag
+        * @param $input
+        * @param $args
+        * @param $parser Parser
+        * @return string
+        */
        public static function renderTag($input, $args, $parser) {
                try {
                        global $wgLua;
                        # Create a new LuaWrapper if needed
-                       if (!isset($wgLua))
+                       if ( $wgLua === null ) {
                                $wgLua = new LuaWrapper;
+                       }
 
                        # Process the tag's arguments into a chunk of Lua code
                        # that initializes them in the Lua sandbox
@@ -55,17 +66,24 @@
                        return $e->getMessage();
                }
        }
-       
-       /** Parser function hook for the #luaexpr function */
+
+       /**
+        * Parser function hook for the #luaexpr function
+        * @param $parser Parser
+        * @param $param1 bool
+        * @return string
+        */
        public static function renderExpr(&$parser, $param1 = FALSE) {
                global $wgLua;
                # Create a new LuaWrapper if needed
-               if (!isset($wgLua))
-                       $wgLua = LuaWrapper::create();
+               if ( $wgLua === null ) {
+                       $wgLua = new LuaWrapper;
+               }
                
                # Execute this Lua chunk, wrapped in io.write().
-               if ($param1 == FALSE)
+               if ( $param1 == false ) {
                        return '';
+               }
                try {
                        return $wgLua->wrap("io.write($param1)");
                } catch (LuaError $e) {

Modified: trunk/extensions/Lua/Lua.php
===================================================================
--- trunk/extensions/Lua/Lua.php        2012-01-26 20:59:58 UTC (rev 110081)
+++ trunk/extensions/Lua/Lua.php        2012-01-26 21:01:11 UTC (rev 110082)
@@ -23,8 +23,12 @@
 $wgAutoloadClasses['LuaError'] = $dir . 'Lua.wrapper.php';
 $wgAutoloadClasses['LuaWrapper'] = $dir . 'Lua.wrapper.php';
 
-$wgLuaExternalInterpreter = FALSE;
-$wgLuaExternalCompiler = FALSE;
+/**
+ * @var $wgLua LuaWrapper
+ */
+$wgLua = null;
+$wgLuaExternalInterpreter = false;
+$wgLuaExternalCompiler = false;
 $wgLuaExtension = 'lua';
 $wgLuaMaxLines = 1000000;
 $wgLuaMaxCalls = 2000;

Modified: trunk/extensions/Lua/Lua.wrapper.php
===================================================================
--- trunk/extensions/Lua/Lua.wrapper.php        2012-01-26 20:59:58 UTC (rev 
110081)
+++ trunk/extensions/Lua/Lua.wrapper.php        2012-01-26 21:01:11 UTC (rev 
110082)
@@ -19,7 +19,6 @@
         * @param $parameter \type{\string} Optional parameter for that message
         */
        public function __construct($msg, $parameter = ''){
-
                $this->message = '<strong class="error">' . wfMsgForContent( 
"lua_$msg", htmlspecialchars( $parameter ) ) . '</strong>';
        }
 }
@@ -67,7 +66,7 @@
                                                      1 => array('pipe', 'w')),
                                                $this->pipes, null, null);
                        if (!is_resource($this->proc)) {
-                               $this->defunct = TRUE;
+                               $this->defunct = true;
                                throw new LuaError('interp_notfound');
                        }
                        stream_set_blocking($this->pipes[0], 0);
@@ -76,12 +75,12 @@
                        stream_set_write_buffer($this->pipes[1], 0);
 
                        # Ready to go.
-                       $this->defunct = FALSE;
-                       return TRUE;
+                       $this->defunct = false;
+                       return true;
                } elseif ( $wgLuaExtension === 'lua' ) {
                        # We're using the extension - verify it exists
                        if (!class_exists('lua')) {
-                               $this->defunct = TRUE;
+                               $this->defunct = true;
                                throw new LuaError('extension_notfound');
                        }
 
@@ -96,11 +95,11 @@
                        }
 
                        # Ready to go.
-                       $this->defunct = FALSE;
+                       $this->defunct = false;
                        return TRUE;
                } elseif ( $wgLuaExtension === 'luasandbox' ) {
                        if (!class_exists('luasandbox')) {
-                               $this->defunct = TRUE;
+                               $this->defunct = true;
                                throw new LuaError( 'extension_notfound' );
                        }
 
@@ -217,7 +216,7 @@
        public function destroy() {
                # If we're already defunct, we're done
                if ($this->defunct)
-                       return FALSE;
+                       return false;
 
                # Destroy the lua instance and/or external process and pipes
                if ( isset( $this->sandbox ) ) {
@@ -233,8 +232,8 @@
                }
 
                # Mark this instance defunct
-               $this->defunct = TRUE;
-               return TRUE;
+               $this->defunct = true;
+               return true;
        }
 
        public function luaPrint() {


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to