r110082 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110081‎ | r110082 | r110083 >
Date:21:01, 26 January 2012
Author:reedy
Status:ok
Tags:
Comment:
Fix register_globals

lowercase bools
Modified paths:
  • /trunk/extensions/Lua/Lua.hooks.php (modified) (history)
  • /trunk/extensions/Lua/Lua.php (modified) (history)
  • /trunk/extensions/Lua/Lua.wrapper.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Lua/Lua.wrapper.php
@@ -19,7 +19,6 @@
2020 * @param $parameter \type{\string} Optional parameter for that message
2121 */
2222 public function __construct($msg, $parameter = ''){
23 -
2423 $this->message = '<strong class="error">' . wfMsgForContent( "lua_$msg", htmlspecialchars( $parameter ) ) . '</strong>';
2524 }
2625 }
@@ -67,7 +66,7 @@
6867 1 => array('pipe', 'w')),
6968 $this->pipes, null, null);
7069 if (!is_resource($this->proc)) {
71 - $this->defunct = TRUE;
 70+ $this->defunct = true;
7271 throw new LuaError('interp_notfound');
7372 }
7473 stream_set_blocking($this->pipes[0], 0);
@@ -76,12 +75,12 @@
7776 stream_set_write_buffer($this->pipes[1], 0);
7877
7978 # Ready to go.
80 - $this->defunct = FALSE;
81 - return TRUE;
 79+ $this->defunct = false;
 80+ return true;
8281 } elseif ( $wgLuaExtension === 'lua' ) {
8382 # We're using the extension - verify it exists
8483 if (!class_exists('lua')) {
85 - $this->defunct = TRUE;
 84+ $this->defunct = true;
8685 throw new LuaError('extension_notfound');
8786 }
8887
@@ -96,11 +95,11 @@
9796 }
9897
9998 # Ready to go.
100 - $this->defunct = FALSE;
 99+ $this->defunct = false;
101100 return TRUE;
102101 } elseif ( $wgLuaExtension === 'luasandbox' ) {
103102 if (!class_exists('luasandbox')) {
104 - $this->defunct = TRUE;
 103+ $this->defunct = true;
105104 throw new LuaError( 'extension_notfound' );
106105 }
107106
@@ -217,7 +216,7 @@
218217 public function destroy() {
219218 # If we're already defunct, we're done
220219 if ($this->defunct)
221 - return FALSE;
 220+ return false;
222221
223222 # Destroy the lua instance and/or external process and pipes
224223 if ( isset( $this->sandbox ) ) {
@@ -233,8 +232,8 @@
234233 }
235234
236235 # Mark this instance defunct
237 - $this->defunct = TRUE;
238 - return TRUE;
 236+ $this->defunct = true;
 237+ return true;
239238 }
240239
241240 public function luaPrint() {
Index: trunk/extensions/Lua/Lua.php
@@ -23,8 +23,12 @@
2424 $wgAutoloadClasses['LuaError'] = $dir . 'Lua.wrapper.php';
2525 $wgAutoloadClasses['LuaWrapper'] = $dir . 'Lua.wrapper.php';
2626
27 -$wgLuaExternalInterpreter = FALSE;
28 -$wgLuaExternalCompiler = FALSE;
 27+/**
 28+ * @var $wgLua LuaWrapper
 29+ */
 30+$wgLua = null;
 31+$wgLuaExternalInterpreter = false;
 32+$wgLuaExternalCompiler = false;
2933 $wgLuaExtension = 'lua';
3034 $wgLuaMaxLines = 1000000;
3135 $wgLuaMaxCalls = 2000;
Index: trunk/extensions/Lua/Lua.hooks.php
@@ -9,7 +9,11 @@
1010 */
1111
1212 class LuaHooks {
13 - /** ParserFirstCallInit hook */
 13+ /**
 14+ * ParserFirstCallInit hook
 15+ * @param $parser Parser
 16+ * @return bool
 17+ */
1418 public static function parserInit( &$parser ) {
1519 $parser->setHook( 'lua', 'LuaHooks::renderTag' );
1620 $parser->setFunctionHook('luaexpr', 'LuaHooks::renderExpr');
@@ -19,19 +23,26 @@
2024 /** ParserBeforeTidy hook */
2125 public static function beforeTidy(&$parser, &$text) {
2226 global $wgLua;
23 - if (isset($wgLua)) {
 27+ if ( $wgLua !== null ) {
2428 $wgLua->destroy();
2529 }
26 - return TRUE;
 30+ return true;
2731 }
2832
29 - /** Parser hook for the <lua> tag */
 33+ /**
 34+ * Parser hook for the <lua> tag
 35+ * @param $input
 36+ * @param $args
 37+ * @param $parser Parser
 38+ * @return string
 39+ */
3040 public static function renderTag($input, $args, $parser) {
3141 try {
3242 global $wgLua;
3343 # Create a new LuaWrapper if needed
34 - if (!isset($wgLua))
 44+ if ( $wgLua === null ) {
3545 $wgLua = new LuaWrapper;
 46+ }
3647
3748 # Process the tag's arguments into a chunk of Lua code
3849 # that initializes them in the Lua sandbox
@@ -55,17 +66,24 @@
5667 return $e->getMessage();
5768 }
5869 }
59 -
60 - /** Parser function hook for the #luaexpr function */
 70+
 71+ /**
 72+ * Parser function hook for the #luaexpr function
 73+ * @param $parser Parser
 74+ * @param $param1 bool
 75+ * @return string
 76+ */
6177 public static function renderExpr(&$parser, $param1 = FALSE) {
6278 global $wgLua;
6379 # Create a new LuaWrapper if needed
64 - if (!isset($wgLua))
65 - $wgLua = LuaWrapper::create();
 80+ if ( $wgLua === null ) {
 81+ $wgLua = new LuaWrapper;
 82+ }
6683
6784 # Execute this Lua chunk, wrapped in io.write().
68 - if ($param1 == FALSE)
 85+ if ( $param1 == false ) {
6986 return '';
 87+ }
7088 try {
7189 return $wgLua->wrap("io.write($param1)");
7290 } catch (LuaError $e) {

Status & tagging log