Index: trunk/extensions/Scripting/common/Hooks.php |
— | — | @@ -56,16 +56,15 @@ |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Handles the {{#invoke:module|func}} construction. |
60 | | - * |
61 | | - * @static |
62 | | - * @param $parser Parser |
63 | | - * @param $frame |
64 | | - * @param $args |
| 60 | + * |
| 61 | + * @param $parser Parser |
| 62 | + * @param $frame PPFrame |
| 63 | + * @param $args array |
65 | 64 | * @return string |
66 | 65 | */ |
67 | 66 | public static function callHook( &$parser, $frame, $args ) { |
68 | 67 | if( count( $args ) < 2 ) { |
69 | | - throw new ScriptingException( 'nofunction', 'common' ); // scripting-exceptions-common-nofunction |
| 68 | + throw new ScriptingException( 'nofunction', 'common' ); // scripting-exceptions-common-nofunction |
70 | 69 | } |
71 | 70 | |
72 | 71 | $module = $parser->mStripState->unstripBoth( array_shift( $args ) ); |
— | — | @@ -75,11 +74,10 @@ |
76 | 75 | |
77 | 76 | /** |
78 | 77 | * Handles the transclusion of the script ({{script:module}} hook). |
79 | | - * |
80 | | - * @static |
81 | | - * @param $parser Parser |
82 | | - * @param $frame |
83 | | - * @param $args |
| 78 | + * |
| 79 | + * @param $parser Parser |
| 80 | + * @param $frame PPFrame |
| 81 | + * @param $args |
84 | 82 | * @return string |
85 | 83 | */ |
86 | 84 | public static function transcludeHook( &$parser, $frame, $args ) { |
— | — | @@ -87,6 +85,15 @@ |
88 | 86 | return self::doRunHook( $parser, $frame, $module, 'main', $args ); |
89 | 87 | } |
90 | 88 | |
| 89 | + /** |
| 90 | + * @param $parser Parser |
| 91 | + * @param $frame PPFrame |
| 92 | + * @param $module |
| 93 | + * @param $function |
| 94 | + * @param $args |
| 95 | + * @return string |
| 96 | + * @throws ScriptingException |
| 97 | + */ |
91 | 98 | private static function doRunHook( &$parser, $frame, $module, $function, $args ) { |
92 | 99 | wfProfileIn( __METHOD__ ); |
93 | 100 | |
— | — | @@ -118,11 +125,10 @@ |
119 | 126 | /** |
120 | 127 | * Overrides the standard view for modules. Enables syntax highlighting when |
121 | 128 | * possible. |
122 | | - * |
123 | | - * @static |
124 | | - * @param $text |
125 | | - * @param $title Title |
126 | | - * @param $output OutputPage |
| 129 | + * |
| 130 | + * @param $text string |
| 131 | + * @param $title Title |
| 132 | + * @param $output OutputPage |
127 | 133 | * @return bool |
128 | 134 | */ |
129 | 135 | public static function handleScriptView( $text, $title, $output ) { |
— | — | @@ -157,6 +163,9 @@ |
158 | 164 | |
159 | 165 | /** |
160 | 166 | * Indicates that modules are not wikitext. |
| 167 | + * @param $title Title |
| 168 | + * @param $result |
| 169 | + * @return bool |
161 | 170 | */ |
162 | 171 | public static function isWikitextPage( $title, &$result ) { |
163 | 172 | if( $title->getNamespace() == NS_MODULE ) { |
— | — | @@ -169,9 +178,8 @@ |
170 | 179 | /** |
171 | 180 | * Adds report of number of evaluations by the single wikitext page. |
172 | 181 | * |
173 | | - * @static |
174 | | - * @param $parser Parser |
175 | | - * @param $report |
| 182 | + * @param $parser Parser |
| 183 | + * @param $report |
176 | 184 | * @return bool |
177 | 185 | */ |
178 | 186 | public static function reportLimits( $parser, &$report ) { |
— | — | @@ -218,7 +226,7 @@ |
219 | 227 | |
220 | 228 | return true; |
221 | 229 | } |
222 | | - |
| 230 | + |
223 | 231 | return true; |
224 | 232 | } |
225 | 233 | } |
Index: trunk/extensions/Scripting/common/LinkUpdates.php |
— | — | @@ -58,17 +58,21 @@ |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Purges cache for all the pages where the script is used. |
| 62 | + * @param $article Article |
| 63 | + * @param $editInfo |
| 64 | + * @param $changed |
| 65 | + * @return bool |
62 | 66 | */ |
63 | 67 | public static function purgeCache( &$article, &$editInfo, $changed ) { |
64 | 68 | global $wgDeferredUpdateList, $wgParser; |
65 | 69 | |
66 | | - if( $article->mTitle->getNamespace() == NS_MODULE ) { |
| 70 | + if( $article->getTitle()->getNamespace() == NS_MODULE ) { |
67 | 71 | // Invalidate the script cache |
68 | 72 | $engine = Scripting::getEngine( $wgParser ); |
69 | | - $engine->invalidateModuleCache( $article->mTitle ); |
| 73 | + $engine->invalidateModuleCache( $article->getTitle() ); |
70 | 74 | |
71 | 75 | // Invalidate caches of articles which include the script |
72 | | - $wgDeferredUpdateList[] = new HTMLCacheUpdate( $article->mTitle, 'scriptlinks' ); |
| 76 | + $wgDeferredUpdateList[] = new HTMLCacheUpdate( $article->getTitle(), 'scriptlinks' ); |
73 | 77 | } |
74 | 78 | |
75 | 79 | return true; |
— | — | @@ -88,6 +92,10 @@ |
89 | 93 | |
90 | 94 | /** |
91 | 95 | * Adds scriptlinks to the list of tables supported by BacklinkCache. |
| 96 | + * @param $table |
| 97 | + * @param $title Title |
| 98 | + * @param $conds |
| 99 | + * @return bool |
92 | 100 | */ |
93 | 101 | public static function getBacklinkCacheConditions( $table, $title, &$conds ) { |
94 | 102 | if( $table == 'scriptlinks' ) { |
Index: trunk/extensions/Scripting/common/Common.php |
— | — | @@ -8,21 +8,21 @@ |
9 | 9 | |
10 | 10 | protected static function getEngineClass() { |
11 | 11 | global $wgScriptingEngine, $wgScriptingEngines; |
12 | | - |
| 12 | + |
13 | 13 | if( !$wgScriptingEngine ) { |
14 | 14 | throw new MWException( 'Scripting extension is enabled but $wgScriptingEngine is not set' ); |
15 | 15 | } |
16 | | - |
| 16 | + |
17 | 17 | if( !isset( $wgScriptingEngines[$wgScriptingEngine] ) ) { |
18 | 18 | throw new MWException( 'Invalid scripting engine is specified in $wgScriptingEngine' ); |
19 | 19 | } |
20 | | - |
| 20 | + |
21 | 21 | return $wgScriptingEngines[$wgScriptingEngine]; |
22 | 22 | } |
23 | | - |
| 23 | + |
24 | 24 | public static function getEngine( $parser ) { |
25 | 25 | global $wgScriptingEngineConf; |
26 | | - |
| 26 | + |
27 | 27 | if( !isset( $parser->scripting_engine ) || !$parser->scripting_engine ) { |
28 | 28 | $class = self::getEngineClass(); |
29 | 29 | $parser->scripting_engine = new $class( $parser ); |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | } |
32 | 32 | return $parser->scripting_engine; |
33 | 33 | } |
34 | | - |
| 34 | + |
35 | 35 | public static function resetEngine( $parser ) { |
36 | 36 | $parser->scripting_engine = null; |
37 | 37 | } |
Index: trunk/extensions/Scripting/engines/LuaSandbox/Engine.php |
— | — | @@ -2,16 +2,17 @@ |
3 | 3 | |
4 | 4 | class LuaSandboxEngine extends ScriptingEngineBase { |
5 | 5 | public $mSandbox; |
6 | | - |
| 6 | + |
7 | 7 | public function load() { |
8 | | - if( $this->mLoaded ) |
| 8 | + if( $this->mLoaded ) { |
9 | 9 | return; |
| 10 | + } |
10 | 11 | |
11 | | - if( !class_exists('luasandbox') ) { |
| 12 | + if( !MWInit::classExists( 'luasandbox' ) ) { |
12 | 13 | throw new MWException( 'luasandbox PHP extension is not installed' ); |
13 | 14 | } |
14 | 15 | |
15 | | - $this->mSandbox = new LuaSandbox; |
| 16 | + $this->mSandbox = new LuaSandbox; |
16 | 17 | $this->mSandbox->setMemoryLimit( $this->mOptions['memoryLimit'] ); |
17 | 18 | $this->mSandbox->setCPULimit( $this->mOptions['maxCPU'] ); |
18 | 19 | $this->mSandbox->registerLibrary( 'mw', array( 'import' => array( $this, 'importModule' ) ) ); |
— | — | @@ -78,12 +79,13 @@ |
79 | 80 | protected $mInitialized; |
80 | 81 | |
81 | 82 | function initialize() { |
82 | | - if( $this->mInitialized ) |
| 83 | + if( $this->mInitialized ) { |
83 | 84 | return; |
| 85 | + } |
84 | 86 | $this->mEngine->load(); |
85 | | - |
| 87 | + |
86 | 88 | // FIXME: caching? |
87 | | - |
| 89 | + |
88 | 90 | try { |
89 | 91 | $this->mBody = $this->mEngine->mSandbox->loadString( $this->mCode ); |
90 | 92 | $output = $this->mBody->call(); |