Index: trunk/extensions/Scripting/common/Common.php |
— | — | @@ -37,9 +37,8 @@ |
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | | - * Exceptions which represents user-originating error in the script. |
42 | | - * Please do not use it for internal errors like "oh god, this should have never happened". |
43 | | - * Use casual MWException for that. |
| 41 | + * An exception class which represents an error in the script. This does not |
| 42 | + * normally abort the request, instead it is caught and shown to the user. |
44 | 43 | */ |
45 | 44 | class ScriptingException extends MWException { |
46 | 45 | function __construct( $exceptionID, $engine, $module = null, $line = null, $params = array() ) { |
— | — | @@ -51,13 +50,13 @@ |
52 | 51 | } |
53 | 52 | parent::__construct( $msg ); |
54 | 53 | |
55 | | - $this->mExceptionID = $exceptionID; |
56 | | - $this->mLine = $line; |
57 | | - $this->mModule = $module; |
58 | | - $this->mParams = $params; |
| 54 | + $this->exceptionID = $exceptionID; |
| 55 | + $this->line = $line; |
| 56 | + $this->module = $module; |
| 57 | + $this->params = $params; |
59 | 58 | } |
60 | 59 | |
61 | 60 | public function getExceptionID() { |
62 | | - return $this->mExceptionID; |
| 61 | + return $this->exceptionID; |
63 | 62 | } |
64 | 63 | } |
Index: trunk/extensions/Scripting/common/Base.php |
— | — | @@ -28,9 +28,9 @@ |
29 | 29 | */ |
30 | 30 | abstract class ScriptingEngineBase { |
31 | 31 | protected |
32 | | - $mParser, |
33 | | - $mModules = array(), |
34 | | - $mModuleTitles = array(); |
| 32 | + $parser, |
| 33 | + $modules = array(), |
| 34 | + $moduleTitles = array(); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Creates a new module object within this engine |
— | — | @@ -40,7 +40,9 @@ |
41 | 41 | /** |
42 | 42 | * Returns the default options of the engine. |
43 | 43 | */ |
44 | | - abstract public function getDefaultOptions(); |
| 44 | + public function getDefaultOptions() { |
| 45 | + return array(); |
| 46 | + } |
45 | 47 | |
46 | 48 | /** |
47 | 49 | * Is called by setOptions() in order to notify the engine |
— | — | @@ -54,7 +56,7 @@ |
55 | 57 | * @param $parser Parser Wikitext parser |
56 | 58 | */ |
57 | 59 | public function __construct( $parser ) { |
58 | | - $this->mParser = $parser; |
| 60 | + $this->parser = $parser; |
59 | 61 | } |
60 | 62 | |
61 | 63 | /** |
— | — | @@ -78,7 +80,7 @@ |
79 | 81 | |
80 | 82 | // Check if it is already loaded |
81 | 83 | $key = $title->getPrefixedText(); |
82 | | - if( !isset( $this->mModules[$key] ) ) { |
| 84 | + if( !isset( $this->modules[$key] ) ) { |
83 | 85 | // Fetch the text |
84 | 86 | $rev = $this->getModuleRev( $title, $source ); |
85 | 87 | if( !$rev ) { |
— | — | @@ -89,10 +91,10 @@ |
90 | 92 | } |
91 | 93 | |
92 | 94 | // Create the class |
93 | | - $this->mModules[$key] = $this->newModule( $title, $rev->getText(), $rev->getID(), $source ); |
94 | | - $this->mModuleTitles[] = $title; |
| 95 | + $this->modules[$key] = $this->newModule( $title, $rev->getText(), $rev->getID(), $source ); |
| 96 | + $this->moduleTitles[] = $title; |
95 | 97 | } |
96 | | - return $this->mModules[$key]; |
| 98 | + return $this->modules[$key]; |
97 | 99 | } |
98 | 100 | |
99 | 101 | /** |
— | — | @@ -114,7 +116,7 @@ |
115 | 117 | * Sets the engine-specific options from $wgScriptingEngineConf. |
116 | 118 | */ |
117 | 119 | function setOptions( $options ) { |
118 | | - $this->mOptions = array_merge( $this->getDefaultOptions(), $options ); |
| 120 | + $this->options = array_merge( $this->getDefaultOptions(), $options ); |
119 | 121 | $this->updateOptions(); |
120 | 122 | } |
121 | 123 | |
— | — | @@ -152,7 +154,7 @@ |
153 | 155 | * engine. |
154 | 156 | */ |
155 | 157 | public function getUsedModules() { |
156 | | - return $this->mModuleTitles; |
| 158 | + return $this->moduleTitles; |
157 | 159 | } |
158 | 160 | |
159 | 161 | /** |
— | — | @@ -183,22 +185,22 @@ |
184 | 186 | * and maintaining the contents of the module. |
185 | 187 | */ |
186 | 188 | abstract class ScriptingModuleBase { |
187 | | - var $mEngine, $mTitle, $mCode, $mRevisionID, $mSource; |
| 189 | + var $engine, $title, $code, $revisionID, $source; |
188 | 190 | |
189 | 191 | public function __construct( $engine, $title, $code, $revisionID, $source ) { |
190 | | - $this->mEngine = $engine; |
191 | | - $this->mTitle = $title; |
192 | | - $this->mCode = $code; |
193 | | - $this->mRevisionID = $revisionID; |
194 | | - $this->mSource = $source; |
| 192 | + $this->engine = $engine; |
| 193 | + $this->title = $title; |
| 194 | + $this->code = $code; |
| 195 | + $this->revisionID = $revisionID; |
| 196 | + $this->source = $source; |
195 | 197 | } |
196 | 198 | |
197 | 199 | /** Accessors **/ |
198 | | - public function getEngine() { return $this->mEngine; } |
199 | | - public function getTitle() { return $this->mTitle; } |
200 | | - public function getCode() { return $this->mCode; } |
201 | | - public function getRevisionID() { return $this->mRevisionID; } |
202 | | - public function getSource() { return $this->mSource; } |
| 200 | + public function getEngine() { return $this->engine; } |
| 201 | + public function getTitle() { return $this->title; } |
| 202 | + public function getCode() { return $this->code; } |
| 203 | + public function getRevisionID() { return $this->revisionID; } |
| 204 | + public function getSource() { return $this->source; } |
203 | 205 | |
204 | 206 | /** |
205 | 207 | * Initialize the module. That means parse it and load the |
— | — | @@ -227,10 +229,10 @@ |
228 | 230 | protected $mName, $mContents, $mModule, $mEngine; |
229 | 231 | |
230 | 232 | public function __construct( $module, $name, $contents ) { |
231 | | - $this->mName = $name; |
232 | | - $this->mContents = $contents; |
233 | | - $this->mModule = $module; |
234 | | - $this->mEngine = $module->getEngine(); |
| 233 | + $this->name = $name; |
| 234 | + $this->contents = $contents; |
| 235 | + $this->module = $module; |
| 236 | + $this->engine = $module->getEngine(); |
235 | 237 | } |
236 | 238 | |
237 | 239 | /** |
— | — | @@ -242,7 +244,7 @@ |
243 | 245 | abstract public function call( $args, $frame ); |
244 | 246 | |
245 | 247 | /** Accessors **/ |
246 | | - public function getName() { return $this->mName; } |
247 | | - public function getModule() { return $this->mModule; } |
248 | | - public function getEngine() { return $this->mEngine; } |
| 248 | + public function getName() { return $this->name; } |
| 249 | + public function getModule() { return $this->module; } |
| 250 | + public function getEngine() { return $this->engine; } |
249 | 251 | } |
Index: trunk/extensions/Scripting/common/LinkUpdates.php |
— | — | @@ -115,12 +115,12 @@ |
116 | 116 | * with templates. |
117 | 117 | */ |
118 | 118 | class ScriptLinksUpdate { |
119 | | - var $mUpdate, $mId, $mNew; |
| 119 | + var $update, $id, $new; |
120 | 120 | |
121 | 121 | public function __construct( $update, $new ) { |
122 | | - $this->mUpdate = $update; |
123 | | - $this->mId = $update->mId; |
124 | | - $this->mNew = $new; |
| 122 | + $this->update = $update; |
| 123 | + $this->id = $update->mId; |
| 124 | + $this->new = $new; |
125 | 125 | } |
126 | 126 | |
127 | 127 | public function run() { |
— | — | @@ -129,14 +129,14 @@ |
130 | 130 | wfProfileIn( __METHOD__ ); |
131 | 131 | |
132 | 132 | if( $wgUseDumbLinkUpdate ) { |
133 | | - $this->mUpdate->dumbTableUpdate( 'scriptlinks', $this->getScriptInsertions(), 'sl_from' ); |
| 133 | + $this->update->dumbTableUpdate( 'scriptlinks', $this->getScriptInsertions(), 'sl_from' ); |
134 | 134 | } else { |
135 | 135 | $existing = $this->getExistingScripts(); |
136 | | - $this->mUpdate->incrTableUpdate( 'scriptlinks', 'sl', $this->getScriptDeletions( $existing ), |
| 136 | + $this->update->incrTableUpdate( 'scriptlinks', 'sl', $this->getScriptDeletions( $existing ), |
137 | 137 | $this->getScriptInsertions( $existing ) ); |
138 | 138 | } |
139 | 139 | |
140 | | - if( $this->mUpdate->mRecursive && $this->mUpdate->mTitle->getNamespace() == NS_MODULE ) { |
| 140 | + if( $this->update->mRecursive && $this->update->mTitle->getNamespace() == NS_MODULE ) { |
141 | 141 | $this->queueRecursiveJobs(); |
142 | 142 | } |
143 | 143 | |
— | — | @@ -146,8 +146,8 @@ |
147 | 147 | protected function getExistingScripts() { |
148 | 148 | $result = array(); |
149 | 149 | |
150 | | - $res = $this->mUpdate->mDb->select( 'scriptlinks', array( 'sl_to' ), |
151 | | - array( 'sl_from' => $this->mId ), __METHOD__, $this->mUpdate->mOptions ); |
| 150 | + $res = $this->update->mDb->select( 'scriptlinks', array( 'sl_to' ), |
| 151 | + array( 'sl_from' => $this->id ), __METHOD__, $this->update->mOptions ); |
152 | 152 | foreach ( $res as $row ) { |
153 | 153 | $result[] = $row->sl_to; |
154 | 154 | } |
— | — | @@ -158,9 +158,9 @@ |
159 | 159 | protected function getScriptInsertions( $existing = array() ) { |
160 | 160 | $result = array(); |
161 | 161 | |
162 | | - foreach( array_diff( $this->mNew, $existing ) as $module ) { |
| 162 | + foreach( array_diff( $this->new, $existing ) as $module ) { |
163 | 163 | $result[] = array( |
164 | | - 'sl_from' => $this->mId, |
| 164 | + 'sl_from' => $this->id, |
165 | 165 | 'sl_to' => $module, |
166 | 166 | ); |
167 | 167 | } |
— | — | @@ -171,9 +171,9 @@ |
172 | 172 | protected function getScriptDeletions( $existing = array() ) { |
173 | 173 | $result = array(); |
174 | 174 | |
175 | | - foreach( array_diff( $existing, $this->mNew ) as $module ) { |
| 175 | + foreach( array_diff( $existing, $this->new ) as $module ) { |
176 | 176 | $result[] = array( |
177 | | - 'sl_from' => $this->mId, |
| 177 | + 'sl_from' => $this->id, |
178 | 178 | 'sl_to' => $module, |
179 | 179 | ); |
180 | 180 | } |
— | — | @@ -185,7 +185,7 @@ |
186 | 186 | global $wgUpdateRowsPerJob; |
187 | 187 | wfProfileIn( __METHOD__ ); |
188 | 188 | |
189 | | - $cache = $this->mUpdate->mTitle->getBacklinkCache(); |
| 189 | + $cache = $this->update->mTitle->getBacklinkCache(); |
190 | 190 | $batches = $cache->partition( 'scriptlinks', $wgUpdateRowsPerJob ); |
191 | 191 | if ( !$batches ) { |
192 | 192 | wfProfileOut( __METHOD__ ); |
— | — | @@ -199,7 +199,7 @@ |
200 | 200 | 'start' => $start, |
201 | 201 | 'end' => $end, |
202 | 202 | ); |
203 | | - $jobs[] = new RefreshLinksJob2( $this->mUpdate->mTitle, $params ); |
| 203 | + $jobs[] = new RefreshLinksJob2( $this->update->mTitle, $params ); |
204 | 204 | } |
205 | 205 | Job::batchInsert( $jobs ); |
206 | 206 | |
Index: trunk/extensions/Scripting/engines/LuaSandbox/Engine.php |
— | — | @@ -1,14 +1,14 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class LuaSandboxEngine extends ScriptingEngineBase { |
5 | | - public $mSandbox, $mLoaded = false; |
| 5 | + public $sandbox, $loaded = false; |
6 | 6 | |
7 | 7 | public function newModule( $title, $code, $revisionID, $source ) { |
8 | 8 | return new LuaSandboxEngineModule( $this, $title, $code, $revisionID, $source ); |
9 | 9 | } |
10 | 10 | |
11 | 11 | public function load() { |
12 | | - if( $this->mLoaded ) { |
| 12 | + if( $this->loaded ) { |
13 | 13 | return; |
14 | 14 | } |
15 | 15 | |
— | — | @@ -16,18 +16,18 @@ |
17 | 17 | throw new MWException( 'luasandbox PHP extension is not installed' ); |
18 | 18 | } |
19 | 19 | |
20 | | - $this->mSandbox = new LuaSandbox; |
21 | | - $this->mSandbox->setMemoryLimit( $this->mOptions['memoryLimit'] ); |
22 | | - $this->mSandbox->setCPULimit( $this->mOptions['maxCPU'] ); |
23 | | - $this->mSandbox->registerLibrary( 'mw', array( 'import' => array( $this, 'importModule' ) ) ); |
| 20 | + $this->sandbox = new LuaSandbox; |
| 21 | + $this->sandbox->setMemoryLimit( $this->options['memoryLimit'] ); |
| 22 | + $this->sandbox->setCPULimit( $this->options['maxCPU'] ); |
| 23 | + $this->sandbox->registerLibrary( 'mw', array( 'import' => array( $this, 'importModule' ) ) ); |
24 | 24 | |
25 | | - $this->mLoaded = true; |
| 25 | + $this->loaded = true; |
26 | 26 | } |
27 | 27 | |
28 | 28 | protected function updateOptions() { |
29 | | - if( $this->mLoaded ) { |
30 | | - $this->mSandbox->setMemoryLimit( $this->mOptions['memoryLimit'] ); |
31 | | - $this->mSandbox->setCPULimit( $this->mOptions['maxCPU'] ); |
| 29 | + if( $this->loaded ) { |
| 30 | + $this->sandbox->setMemoryLimit( $this->options['memoryLimit'] ); |
| 31 | + $this->sandbox->setCPULimit( $this->options['maxCPU'] ); |
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
— | — | @@ -53,7 +53,7 @@ |
54 | 54 | public function getLimitsReport() { |
55 | 55 | $this->load(); |
56 | 56 | |
57 | | - $usage = $this->mSandbox->getMemoryUsage(); |
| 57 | + $usage = $this->sandbox->getMemoryUsage(); |
58 | 58 | if( $usage < 8 * 1024 ) { |
59 | 59 | $usageStr = $usage . " bytes"; |
60 | 60 | } elseif( $usage < 8 * 1024 * 1024 ) { |
— | — | @@ -74,27 +74,27 @@ |
75 | 75 | |
76 | 76 | $module = $this->getModule( $args[0] ); |
77 | 77 | $module->initialize(); |
78 | | - return $module->mContents; |
| 78 | + return $module->contents; |
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | 82 | class LuaSandboxEngineModule extends ScriptingModuleBase { |
83 | | - protected $mInitialized; |
| 83 | + protected $initialized; |
84 | 84 | |
85 | 85 | function initialize() { |
86 | | - if( $this->mInitialized ) { |
| 86 | + if( $this->initialized ) { |
87 | 87 | return; |
88 | 88 | } |
89 | | - $this->mEngine->load(); |
| 89 | + $this->engine->load(); |
90 | 90 | |
91 | 91 | // FIXME: caching? |
92 | 92 | |
93 | 93 | try { |
94 | | - $this->mBody = $this->mEngine->mSandbox->loadString( |
95 | | - $this->mCode, |
| 94 | + $this->body = $this->engine->sandbox->loadString( |
| 95 | + $this->code, |
96 | 96 | // Prepending an "@" to the chunk name makes Lua think it is a file name |
97 | 97 | '@' . $this->getTitle()->getPrefixedDBkey() ); |
98 | | - $output = $this->mBody->call(); |
| 98 | + $output = $this->body->call(); |
99 | 99 | } catch( LuaSandboxError $e ) { |
100 | 100 | throw new ScriptingException( 'error', 'luasandbox', null, null, array( $e->getMessage() ) ); |
101 | 101 | } |
— | — | @@ -109,21 +109,21 @@ |
110 | 110 | throw new ScriptingException( 'notarrayreturn', 'luasandbox' ); |
111 | 111 | } |
112 | 112 | |
113 | | - $this->mContents = $output[0]; |
114 | | - $this->mFunctions = array(); |
115 | | - foreach( $this->mContents as $key => $content ) { |
| 113 | + $this->contents = $output[0]; |
| 114 | + $this->functions = array(); |
| 115 | + foreach( $this->contents as $key => $content ) { |
116 | 116 | if( $content instanceof LuaSandboxFunction ) |
117 | | - $this->mFunctions[] = $key; |
| 117 | + $this->functions[] = $key; |
118 | 118 | } |
119 | 119 | |
120 | | - $this->mInitialized = true; |
| 120 | + $this->initialized = true; |
121 | 121 | } |
122 | 122 | |
123 | 123 | function getFunction( $name ) { |
124 | 124 | $this->initialize(); |
125 | 125 | |
126 | | - if( isset( $this->mContents[$name] ) ) { |
127 | | - return new LuaSandboxEngineFunction( $this, $name, $this->mContents[$name] ); |
| 126 | + if( isset( $this->contents[$name] ) ) { |
| 127 | + return new LuaSandboxEngineFunction( $this, $name, $this->contents[$name] ); |
128 | 128 | } else { |
129 | 129 | return null; |
130 | 130 | } |
— | — | @@ -131,14 +131,14 @@ |
132 | 132 | |
133 | 133 | function getFunctions() { |
134 | 134 | $this->initialize(); |
135 | | - return $this->mFunctions; |
| 135 | + return $this->functions; |
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | 139 | class LuaSandboxEngineFunction extends ScriptingFunctionBase { |
140 | 140 | public function call( $args, $frame ) { |
141 | 141 | try { |
142 | | - $result = call_user_func_array( array( $this->mContents, 'call' ), $args ); |
| 142 | + $result = call_user_func_array( array( $this->contents, 'call' ), $args ); |
143 | 143 | } catch( LuaSandboxError $e ) { |
144 | 144 | throw new ScriptingException( 'error', 'luasandbox', null, null, array( $e->getMessage() ) ); |
145 | 145 | } |