r108201 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108200‎ | r108201 | r108202 >
Date:08:47, 6 January 2012
Author:adamw
Status:deferred (Comments)
Tags:
Comment:
replace hard tabs with spaces
Modified paths:
  • /trunk/extensions/Offline/CachedStorage.php (modified) (history)
  • /trunk/extensions/Offline/DatabaseBz2.php (modified) (history)
  • /trunk/extensions/Offline/DumpReader.php (modified) (history)
  • /trunk/extensions/Offline/Offline.i18n.php (modified) (history)
  • /trunk/extensions/Offline/Offline.php (modified) (history)
  • /trunk/extensions/Offline/SearchBz2.php (modified) (history)
  • /trunk/extensions/Offline/SpecialOffline.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Offline/CachedStorage.php
@@ -6,42 +6,42 @@
77 class CachedStorage
88 {
99 static function fetchIdByTitle($title) {
10 - global $wgRevisionCacheExpiry, $wgMemc;
11 - if ($wgRevisionCacheExpiry) { // TODO a better test for caching
12 - $titlekey = wfMemcKey( 'textid', 'titlehash', md5($title) );
13 - $textid = $wgMemc->get($titlekey);
14 - if (is_int($textid) && $textid > 0)
15 - return $textid;
16 - }
17 - return false;
 10+ global $wgRevisionCacheExpiry, $wgMemc;
 11+ if ($wgRevisionCacheExpiry) { // TODO a better test for caching
 12+ $titlekey = wfMemcKey( 'textid', 'titlehash', md5($title) );
 13+ $textid = $wgMemc->get($titlekey);
 14+ if (is_int($textid) && $textid > 0)
 15+ return $textid;
 16+ }
 17+ return false;
1818 }
1919
2020 static function set($title, $content) {
21 - global $wgRevisionCacheExpiry, $wgMemc;
22 - if (!$wgRevisionCacheExpiry) // caching is not possible
23 - return false;
 21+ global $wgRevisionCacheExpiry, $wgMemc;
 22+ if (!$wgRevisionCacheExpiry) // caching is not possible
 23+ return false;
2424
25 - // we need to assign a sequence to revision text, because
26 - // Article::loadContent expects page.text_id to be an integer.
27 - $seq_key = wfMemcKey('offline', 'textid_seq');
28 - if (!$wgMemc->get($seq_key))
29 - $wgMemc->set($seq_key, 1); // and clear the cache??
 25+ // we need to assign a sequence to revision text, because
 26+ // Article::loadContent expects page.text_id to be an integer.
 27+ $seq_key = wfMemcKey('offline', 'textid_seq');
 28+ if (!$wgMemc->get($seq_key))
 29+ $wgMemc->set($seq_key, 1); // and clear the cache??
3030
31 - $textid = $wgMemc->incr($seq_key);
 31+ $textid = $wgMemc->incr($seq_key);
3232
33 - // cache a lookup from title to fake textid
34 - $titlekey = wfMemcKey( 'textid', 'titlehash', md5($title) );
35 - $wgMemc->set( $titlekey, $textid, $wgRevisionCacheExpiry );
 33+ // cache a lookup from title to fake textid
 34+ $titlekey = wfMemcKey( 'textid', 'titlehash', md5($title) );
 35+ $wgMemc->set( $titlekey, $textid, $wgRevisionCacheExpiry );
3636
37 - // TODO interfering with the cache is necessary to avoid a
38 - // second query on Revision::newFromId. It would be much
39 - // smarter to directly retrieve article markup, and optionally
40 - // cache in the usual way.
41 - $textkey = wfMemcKey( 'revisiontext', 'textid', $textid );
42 - $wgMemc->delete( $textkey );
43 - $wgMemc->set( $textkey, $content, $wgRevisionCacheExpiry );
44 - //wfDebug('Stuffing the cache with '.strlen($content).' bytes, at id='.$textid."\n");
 37+ // TODO interfering with the cache is necessary to avoid a
 38+ // second query on Revision::newFromId. It would be much
 39+ // smarter to directly retrieve article markup, and optionally
 40+ // cache in the usual way.
 41+ $textkey = wfMemcKey( 'revisiontext', 'textid', $textid );
 42+ $wgMemc->delete( $textkey );
 43+ $wgMemc->set( $textkey, $content, $wgRevisionCacheExpiry );
 44+ //wfDebug('Stuffing the cache with '.strlen($content).' bytes, at id='.$textid."\n");
4545
46 - return $textid;
 46+ return $textid;
4747 }
4848 }
Index: trunk/extensions/Offline/Offline.i18n.php
@@ -41,6 +41,46 @@
4242 'offline_live_data_preferred' => 'Matches from the so-called live database will be preferred over dump text.',
4343 );
4444
 45+$messages['qqq'] = array(
 46+ 'offline_desc' => '',
 47+ 'offline' => 'Title on the Special page',
 48+ 'offline_special_desc' => '',
 49+
 50+ 'offline_heading_status' => '',
 51+
 52+ 'offline_test_article' => 'an entry known to exist in your language wiki',
 53+ 'offline_bad_test_article' => '',
 54+
 55+ 'offline_index_test_pass' => '',
 56+ 'offline_index_test_fail' => '',
 57+ 'offlinewikipath_not_configured' => '',
 58+ 'offlinewikipath_not_found' => '',
 59+ 'offline_dbdir_not_found' => '',
 60+ 'offline_unknown_index_error' => '',
 61+
 62+ 'offline_bzload_test_pass' => '',
 63+ 'offline_bzload_test_fail' => '',
 64+ 'offline_bz2_ext_needed' => '',
 65+ 'offline_bz2_file_gone' => '',
 66+ 'offline_unknown_bz2_error' => '',
 67+
 68+ 'offline_article_test_pass' => '',
 69+ 'offline_article_test_fail' => '',
 70+
 71+ 'offline_hooks_test_pass' => '',
 72+ 'offline_hooks_test_fail' => '',
 73+ 'offline_cache_needed' => '',
 74+
 75+ 'offline_all_tests_pass' => '',
 76+
 77+ // user preferences
 78+ 'offline_subdir_status' => '',
 79+ 'offline_change_subdir' => '',
 80+
 81+ 'offline_change_language' => '',
 82+ 'offline_live_data_preferred' => '',
 83+);
 84+
4585 $messages['tl'] = array(
4686 'offline_test_article' => 'Myanmar', // a word likely to be found
4787 );
Index: trunk/extensions/Offline/DatabaseBz2.php
@@ -26,56 +26,58 @@
2727
2828 class DatabaseBz2 extends Database
2929 {
30 - function select( $table, $fields, $conds='', $fname = 'Database::select', $options = array() ) {
31 - require_once(dirname(__FILE__).'/DumpReader.php');
32 - require_once(dirname(__FILE__).'/CachedStorage.php');
33 - $row = array();
34 - $title = false;
35 - if (isset($conds['page_title'])) {
36 - $title = $conds['page_title'];
37 - if ($conds['page_namespace'] && MWNamespace::getCanonicalName($conds['page_namespace']))
38 - $title = MWNamespace::getCanonicalName($conds['page_namespace']).':'.$title;
39 - }
 30+ function select( $table, $fields, $conds='', $fname = 'Database::select', $options = array() )
 31+ {
 32+ require_once(dirname(__FILE__).'/DumpReader.php');
 33+ require_once(dirname(__FILE__).'/CachedStorage.php');
 34+ $row = array();
 35+ $title = false;
 36+ if (isset($conds['page_title'])) {
 37+ $title = $conds['page_title'];
 38+ if ($conds['page_namespace'] && MWNamespace::getCanonicalName($conds['page_namespace']))
 39+ $title = MWNamespace::getCanonicalName($conds['page_namespace']).':'.$title;
 40+ }
4041
41 - if ($title && ($table == 'page' || (is_array($table) && in_array('page', $table)))) {
42 - if (preg_match('/Template:Pp-/i', $title))
43 - return false;
 42+ if ($title && ($table == 'page' || (is_array($table) && in_array('page', $table))))
 43+ {
 44+ if (preg_match('/Template:Pp-/i', $title))
 45+ return false;
4446
45 - $textid = CachedStorage::fetchIdByTitle($title);
46 - if (!$textid) {
47 - $content = DumpReader::load_article($title);
48 - if (!$content) {
 47+ $textid = CachedStorage::fetchIdByTitle($title);
 48+ if (!$textid) {
 49+ $content = DumpReader::load_article($title);
 50+ if (!$content) {
4951 wfDebug('no content for '.$title);
50 - return false;
51 - }
52 - $textid = CachedStorage::set($title, $content);
53 - }
54 - } elseif (isset($conds['rev_id'])) {
55 - $textid = $conds['rev_id'];
56 - }
 52+ return false;
 53+ }
 54+ $textid = CachedStorage::set($title, $content);
 55+ }
 56+ } elseif (isset($conds['rev_id'])) {
 57+ $textid = $conds['rev_id'];
 58+ }
5759
58 - if (!isset($textid))
59 - return $this->resultObject(array());
 60+ if (!isset($textid))
 61+ return $this->resultObject(array());
6062
61 - if ($table == 'page') {
62 - // Given a page_title, get the id of text content. For efficiency,
63 - // we fetch the text and store it by ID to access in case 2.
64 - $row = array_fill_keys($fields, '');
65 - $row['page_id'] = $textid;
66 - $row['page_title'] = $title;
67 - $row['page_latest'] = $textid;
68 - }
69 - elseif ($table == array('page', 'revision')) {
70 - // Redundantly return textid which is cache key to article wml.
71 - $fields[] = 'rev_user';
72 - $fields[] = 'rev_user_text';
73 - $row = array_fill_keys($fields, '');
74 - $row['rev_id'] = $textid;
75 - $row['rev_text_id'] = $textid;
76 - }
77 - else { print_r($table); print_r($conds); }
 63+ if ($table == 'page') {
 64+ // Given a page_title, get the id of text content. For efficiency,
 65+ // we fetch the text and store it by ID to access in case 2.
 66+ $row = array_fill_keys($fields, '');
 67+ $row['page_id'] = $textid;
 68+ $row['page_title'] = $title;
 69+ $row['page_latest'] = $textid;
 70+ }
 71+ elseif ($table == array('page', 'revision')) {
 72+ // Redundantly return textid which is cache key to article wml.
 73+ $fields[] = 'rev_user';
 74+ $fields[] = 'rev_user_text';
 75+ $row = array_fill_keys($fields, '');
 76+ $row['rev_id'] = $textid;
 77+ $row['rev_text_id'] = $textid;
 78+ }
 79+ else { print_r($table); print_r($conds); }
7880
79 - return $this->resultObject($row);
 81+ return $this->resultObject($row);
8082 }
8183
8284
@@ -85,470 +87,470 @@
8688 #------------------------------------------------------------------------------
8789 # Accessors
8890 #------------------------------------------------------------------------------
89 - function failFunction( $function = NULL ) {
90 - return null;
91 - }
 91+ function failFunction( $function = NULL ) {
 92+ return null;
 93+ }
9294
93 - function setOutputPage( $out ) {
94 - return null;
95 - }
 95+ function setOutputPage( $out ) {
 96+ return null;
 97+ }
9698
97 - function debug( $debug = NULL ) {
98 - return null;
99 - }
 99+ function debug( $debug = NULL ) {
 100+ return null;
 101+ }
100102
101 - function bufferResults( $buffer = NULL ) {
102 - return null;
103 - }
 103+ function bufferResults( $buffer = NULL ) {
 104+ return null;
 105+ }
104106
105 - function ignoreErrors( $ignoreErrors = NULL ) {
106 - return true;
107 - }
 107+ function ignoreErrors( $ignoreErrors = NULL ) {
 108+ return true;
 109+ }
108110
109 - function trxLevel( $level = NULL ) {
110 - return 0;
111 - }
 111+ function trxLevel( $level = NULL ) {
 112+ return 0;
 113+ }
112114
113 - function errorCount( $count = NULL ) {
114 - return 0;
115 - }
 115+ function errorCount( $count = NULL ) {
 116+ return 0;
 117+ }
116118
117 - function getLBInfo( $name = NULL ) {
118 - return true;
119 - }
 119+ function getLBInfo( $name = NULL ) {
 120+ return true;
 121+ }
120122
121 - function setLBInfo( $name, $value = NULL ) {
122 - return true;
123 - }
 123+ function setLBInfo( $name, $value = NULL ) {
 124+ return true;
 125+ }
124126
125 - function cascadingDeletes() {
126 - return false;
127 - }
 127+ function cascadingDeletes() {
 128+ return false;
 129+ }
128130
129 - function cleanupTriggers() {
130 - return false;
131 - }
 131+ function cleanupTriggers() {
 132+ return false;
 133+ }
132134
133 - function strictIPs() {
134 - return false;
135 - }
 135+ function strictIPs() {
 136+ return false;
 137+ }
136138
137 - function realTimestamps() {
138 - return false;
139 - }
 139+ function realTimestamps() {
 140+ return false;
 141+ }
140142
141 - function implicitGroupby() {
142 - return true;
143 - }
 143+ function implicitGroupby() {
 144+ return true;
 145+ }
144146
145 - function implicitOrderby() {
146 - return true;
147 - }
 147+ function implicitOrderby() {
 148+ return true;
 149+ }
148150
149 - function searchableIPs() {
150 - return false;
151 - }
 151+ function searchableIPs() {
 152+ return false;
 153+ }
152154
153 - function functionalIndexes() {
154 - return false;
155 - }
 155+ function functionalIndexes() {
 156+ return false;
 157+ }
156158
157 - function lastQuery() {
158 - return true;
159 - }
160 - function isOpen() {
161 - return true;
162 - }
 159+ function lastQuery() {
 160+ return true;
 161+ }
 162+ function isOpen() {
 163+ return true;
 164+ }
163165
164 - function setFlag( $flag ) {
165 - return true;
166 - }
 166+ function setFlag( $flag ) {
 167+ return true;
 168+ }
167169
168 - function clearFlag( $flag ) {
169 - return true;
170 - }
 170+ function clearFlag( $flag ) {
 171+ return true;
 172+ }
171173
172 - function getFlag( $flag ) {
173 - return true;
174 - }
 174+ function getFlag( $flag ) {
 175+ return true;
 176+ }
175177
176 - function getProperty( $name ) {
177 - return true;
178 - }
 178+ function getProperty( $name ) {
 179+ return true;
 180+ }
179181
180182
181 - function __construct( $server = false, $user = false, $password = false, $dbName = false,
182 - $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) {
183 - null;
184 - }
 183+ function __construct( $server = false, $user = false, $password = false, $dbName = false,
 184+ $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) {
 185+ null;
 186+ }
185187
186 - static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0 ) {
187 - return new Database( $server, $user, $password, $dbName, $failFunction, $flags );
188 - }
 188+ static function newFromParams( $server, $user, $password, $dbName, $failFunction = false, $flags = 0 ) {
 189+ return new Database( $server, $user, $password, $dbName, $failFunction, $flags );
 190+ }
189191
190 - function open( $server, $user, $password, $dbName ) {
 192+ function open( $server, $user, $password, $dbName ) {
191193 //TODO test article load using TestDumpReader
192 - return true;
193 - }
 194+ return true;
 195+ }
194196
195 - function close() {
196 - return true;
197 - }
 197+ function close() {
 198+ return true;
 199+ }
198200
199 - function reportConnectionError( $error = 'Unknown error' ) {
200 - return null;
201 - }
 201+ function reportConnectionError( $error = 'Unknown error' ) {
 202+ return null;
 203+ }
202204
203 - public function query( $sql, $fname = '', $tempIgnore = false ) {
204 - return null;
205 - }
 205+ public function query( $sql, $fname = '', $tempIgnore = false ) {
 206+ return null;
 207+ }
206208
207 - function doQuery( $sql ) {
208 - return true;
209 - }
 209+ function doQuery( $sql ) {
 210+ return true;
 211+ }
210212
211 - function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) {
212 - return null;
213 - }
 213+ function reportQueryError( $error, $errno, $sql, $fname, $tempIgnore = false ) {
 214+ return null;
 215+ }
214216
215217
216 - function prepare( $sql, $func = 'Database::prepare' ) {
217 - return null;
218 - }
 218+ function prepare( $sql, $func = 'Database::prepare' ) {
 219+ return null;
 220+ }
219221
220 - function freePrepared( $prepared ) {
221 - return null;
222 - }
 222+ function freePrepared( $prepared ) {
 223+ return null;
 224+ }
223225
224 - function execute( $prepared, $args = null ) {
225 - return true;
226 - }
 226+ function execute( $prepared, $args = null ) {
 227+ return true;
 228+ }
227229
228 - function safeQuery( $query, $args = null ) {
229 - return true;
230 - }
 230+ function safeQuery( $query, $args = null ) {
 231+ return true;
 232+ }
231233
232 - function fillPrepared( $preparedQuery, $args ) {
233 - return true;
234 - }
 234+ function fillPrepared( $preparedQuery, $args ) {
 235+ return true;
 236+ }
235237
236 - function fillPreparedArg( $matches ) {
237 - return true;
238 - }
 238+ function fillPreparedArg( $matches ) {
 239+ return true;
 240+ }
239241
240 - function freeResult( $res ) {
241 - return null;
242 - }
 242+ function freeResult( $res ) {
 243+ return null;
 244+ }
243245
244 - function fetchObject( $res ) {
245 - // cast to object
246 - if (!$res)
247 - return false;
 246+ function fetchObject( $res ) {
 247+ // cast to object
 248+ if (!$res)
 249+ return false;
248250
249 - $array = $res->result;
250 - if(!is_array($array)) {
251 - return $array;
252 - }
253 -
254 - $object = new stdClass();
255 - if (is_array($array) && count($array) > 0) {
256 - foreach ($array as $name=>$value) {
257 - if (!empty($name)) {
258 - $object->$name = $value;
259 - }
260 - }
261 - return $object;
262 - }
263 - else {
264 - return false;
265 - }
266 - }
 251+ $array = $res->result;
 252+ if(!is_array($array)) {
 253+ return $array;
 254+ }
 255+
 256+ $object = new stdClass();
 257+ if (is_array($array) && count($array) > 0) {
 258+ foreach ($array as $name=>$value) {
 259+ if (!empty($name)) {
 260+ $object->$name = $value;
 261+ }
 262+ }
 263+ return $object;
 264+ }
 265+ else {
 266+ return false;
 267+ }
 268+ }
267269
268 - function fetchRow( $res ) {
269 - return null;
270 - }
 270+ function fetchRow( $res ) {
 271+ return null;
 272+ }
271273
272 - function numRows( $res ) {
273 - return 0;
274 - }
 274+ function numRows( $res ) {
 275+ return 0;
 276+ }
275277
276 - function numFields( $res ) {
277 - return 0;
278 - }
 278+ function numFields( $res ) {
 279+ return 0;
 280+ }
279281
280 - function fieldName( $res, $n ) {
281 - return true;
282 - }
 282+ function fieldName( $res, $n ) {
 283+ return true;
 284+ }
283285
284 - function insertId() {
285 - return null;
286 - }
 286+ function insertId() {
 287+ return null;
 288+ }
287289
288 - function dataSeek( $res, $row ) {
289 - return true;
290 - }
 290+ function dataSeek( $res, $row ) {
 291+ return true;
 292+ }
291293
292 - function lastErrno() {
293 - return null;
294 - }
 294+ function lastErrno() {
 295+ return null;
 296+ }
295297
296 - function lastError() {
297 - return null;
298 - }
 298+ function lastError() {
 299+ return null;
 300+ }
299301
300 - function affectedRows() {
301 - return 0;
302 - }
 302+ function affectedRows() {
 303+ return 0;
 304+ }
303305
304 - function set( $table, $var, $value, $cond, $fname = 'Database::set' ) {
305 - return null;
306 - }
 306+ function set( $table, $var, $value, $cond, $fname = 'Database::set' ) {
 307+ return null;
 308+ }
307309
308 - function selectField( $table, $var, $cond='', $fname = 'Database::selectField', $options = array() ) {
309 - return $this->fetchObject($this->select($table, array($var), $cond));
310 - }
 310+ function selectField( $table, $var, $cond='', $fname = 'Database::selectField', $options = array() ) {
 311+ return $this->fetchObject($this->select($table, array($var), $cond));
 312+ }
311313
312 - function makeSelectOptions( $options ) {
313 - return null;
314 - }
 314+ function makeSelectOptions( $options ) {
 315+ return null;
 316+ }
315317
316 - function selectRow( $table, $vars, $conds, $fname = 'Database::selectRow', $options = array() ) {
317 - return $this->fetchObject($this->select($table, $vars, $conds));
318 - }
 318+ function selectRow( $table, $vars, $conds, $fname = 'Database::selectRow', $options = array() ) {
 319+ return $this->fetchObject($this->select($table, $vars, $conds));
 320+ }
319321
320 - function estimateRowCount( $table, $vars='*', $conds='', $fname = 'Database::estimateRowCount', $options = array() ) {
321 - return 0;
322 - }
323 -
 322+ function estimateRowCount( $table, $vars='*', $conds='', $fname = 'Database::estimateRowCount', $options = array() ) {
 323+ return 0;
 324+ }
 325+
324326
325 - static function generalizeSQL( $sql ) {
326 - return null;
327 - }
 327+ static function generalizeSQL( $sql ) {
 328+ return null;
 329+ }
328330
329 - function fieldExists( $table, $field, $fname = 'Database::fieldExists' ) {
330 - return null;
331 - }
 331+ function fieldExists( $table, $field, $fname = 'Database::fieldExists' ) {
 332+ return null;
 333+ }
332334
333 - function indexExists( $table, $index, $fname = 'Database::indexExists' ) {
334 - return null;
335 - }
 335+ function indexExists( $table, $index, $fname = 'Database::indexExists' ) {
 336+ return null;
 337+ }
336338
337339
338 - function indexInfo( $table, $index, $fname = 'Database::indexInfo' ) {
339 - return null;
340 - }
 340+ function indexInfo( $table, $index, $fname = 'Database::indexInfo' ) {
 341+ return null;
 342+ }
341343
342 - function tableExists( $table ) {
343 - return null;
344 - }
 344+ function tableExists( $table ) {
 345+ return null;
 346+ }
345347
346 - function fieldInfo( $table, $field ) {
347 - return null;
348 - }
 348+ function fieldInfo( $table, $field ) {
 349+ return null;
 350+ }
349351
350 - function fieldType( $res, $index ) {
351 - return null;
352 - }
 352+ function fieldType( $res, $index ) {
 353+ return null;
 354+ }
353355
354 - function indexUnique( $table, $index ) {
355 - return null;
356 - }
 356+ function indexUnique( $table, $index ) {
 357+ return null;
 358+ }
357359
358 - function insert( $table, $a, $fname = 'Database::insert', $options = array() ) {
359 - return null;
360 - }
 360+ function insert( $table, $a, $fname = 'Database::insert', $options = array() ) {
 361+ return null;
 362+ }
361363
362 - function makeUpdateOptions( $options ) {
363 - return null;
364 - }
 364+ function makeUpdateOptions( $options ) {
 365+ return null;
 366+ }
365367
366 - function update( $table, $values, $conds, $fname = 'Database::update', $options = array() ) {
367 - return null;
368 - }
 368+ function update( $table, $values, $conds, $fname = 'Database::update', $options = array() ) {
 369+ return null;
 370+ }
369371
370 - function makeList( $a, $mode = LIST_COMMA ) {
371 - return null;
372 - }
 372+ function makeList( $a, $mode = LIST_COMMA ) {
 373+ return null;
 374+ }
373375
374 - function selectDB( $db ) {
375 - return null;
376 - }
 376+ function selectDB( $db ) {
 377+ return null;
 378+ }
377379
378 - function tableName( $name ) {
379 - return null;
380 - }
 380+ function tableName( $name ) {
 381+ return null;
 382+ }
381383
382 - public function tableNames() {
383 - return null;
384 - }
 384+ public function tableNames() {
 385+ return null;
 386+ }
385387
386 - public function tableNamesN() {
387 - return null;
388 - }
 388+ public function tableNamesN() {
 389+ return null;
 390+ }
389391
390 - function tableNamesWithUseIndex( $tables, $use_index ) {
391 - return null;
392 - }
 392+ function tableNamesWithUseIndex( $tables, $use_index ) {
 393+ return null;
 394+ }
393395
394 - function strencode( $s ) {
395 - return true;
396 - }
 396+ function strencode( $s ) {
 397+ return true;
 398+ }
397399
398 - function addQuotes( $s ) {
399 - return true;
400 - }
 400+ function addQuotes( $s ) {
 401+ return true;
 402+ }
401403
402 - function escapeLike( $s ) {
403 - return true;
404 - }
 404+ function escapeLike( $s ) {
 405+ return true;
 406+ }
405407
406 - function nextSequenceValue( $seqName ) {
407 - return null;
408 - }
 408+ function nextSequenceValue( $seqName ) {
 409+ return null;
 410+ }
409411
410 - function useIndexClause( $index ) {
411 - return true;
412 - }
 412+ function useIndexClause( $index ) {
 413+ return true;
 414+ }
413415
414 - function replace( $table, $uniqueIndexes, $rows, $fname = 'Database::replace' ) {
415 - return null;
416 - }
 416+ function replace( $table, $uniqueIndexes, $rows, $fname = 'Database::replace' ) {
 417+ return null;
 418+ }
417419
418 - function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = 'Database::deleteJoin' ) {
419 - return null;
420 - }
 420+ function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds, $fname = 'Database::deleteJoin' ) {
 421+ return null;
 422+ }
421423
422 - function textFieldSize( $table, $field ) {
423 - return null;
424 - }
 424+ function textFieldSize( $table, $field ) {
 425+ return null;
 426+ }
425427
426 - function lowPriorityOption() {
427 - }
 428+ function lowPriorityOption() {
 429+ }
428430
429 - function delete( $table, $conds, $fname = 'Database::delete' ) {
430 - return true;
431 - }
 431+ function delete( $table, $conds, $fname = 'Database::delete' ) {
 432+ return true;
 433+ }
432434
433 - function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'Database::insertSelect',
434 - $insertOptions = array(), $selectOptions = array() )
435 - {
436 - return null;
437 - }
 435+ function insertSelect( $destTable, $srcTable, $varMap, $conds, $fname = 'Database::insertSelect',
 436+ $insertOptions = array(), $selectOptions = array() )
 437+ {
 438+ return null;
 439+ }
438440
439 - function limitResult($sql, $limit, $offset=false) {
440 - return null;
441 - }
 441+ function limitResult($sql, $limit, $offset=false) {
 442+ return null;
 443+ }
442444
443 - function limitResultForUpdate($sql, $num) {
444 - return null;
445 - }
 445+ function limitResultForUpdate($sql, $num) {
 446+ return null;
 447+ }
446448
447 - function conditional( $cond, $trueVal, $falseVal ) {
448 - return null;
449 - }
 449+ function conditional( $cond, $trueVal, $falseVal ) {
 450+ return null;
 451+ }
450452
451 - function wasDeadlock() {
452 - return null;
453 - }
 453+ function wasDeadlock() {
 454+ return null;
 455+ }
454456
455 - function deadlockLoop() {
456 - return null;
457 - }
 457+ function deadlockLoop() {
 458+ return null;
 459+ }
458460
459 - function masterPosWait( $file, $pos, $timeout ) {
460 - return null;
461 - }
 461+ function masterPosWait( $file, $pos, $timeout ) {
 462+ return null;
 463+ }
462464
463 - function getSlavePos() {
464 - return null;
465 - }
 465+ function getSlavePos() {
 466+ return null;
 467+ }
466468
467 - function getMasterPos() {
468 - return null;
469 - }
 469+ function getMasterPos() {
 470+ return null;
 471+ }
470472
471 - function begin( $fname = 'Database::begin' ) {
472 - }
 473+ function begin( $fname = 'Database::begin' ) {
 474+ }
473475
474 - function commit( $fname = 'Database::commit' ) {
475 - }
 476+ function commit( $fname = 'Database::commit' ) {
 477+ }
476478
477 - function rollback( $fname = 'Database::rollback' ) {
478 - }
 479+ function rollback( $fname = 'Database::rollback' ) {
 480+ }
479481
480 - function immediateBegin( $fname = 'Database::immediateBegin' ) {
481 - }
 482+ function immediateBegin( $fname = 'Database::immediateBegin' ) {
 483+ }
482484
483 - function immediateCommit( $fname = 'Database::immediateCommit' ) {
484 - }
 485+ function immediateCommit( $fname = 'Database::immediateCommit' ) {
 486+ }
485487
486 - function timestamp( $ts=0 ) {
487 - }
 488+ function timestamp( $ts=0 ) {
 489+ }
488490
489 - function timestampOrNull( $ts = null ) {
490 - }
 491+ function timestampOrNull( $ts = null ) {
 492+ }
491493
492 - function resultObject( $result ) {
493 - return new ResultWrapper($this, $result);
494 - }
 494+ function resultObject( $result ) {
 495+ return new ResultWrapper($this, $result);
 496+ }
495497
496 - function aggregateValue ($valuedata,$valuename='value') {
497 - }
 498+ function aggregateValue ($valuedata,$valuename='value') {
 499+ }
498500
499 - static function getSoftwareLink() {
500 - return "[http://www.mysql.com/ MySQL]";
501 - }
 501+ static function getSoftwareLink() {
 502+ return "[http://www.mysql.com/ MySQL]";
 503+ }
502504
503 - function getServerVersion() {
504 - }
 505+ function getServerVersion() {
 506+ }
505507
506 - function ping() {
507 - return true;
508 - }
 508+ function ping() {
 509+ return true;
 510+ }
509511
510 - function getLag() {
511 - return 0;
512 - }
 512+ function getLag() {
 513+ return 0;
 514+ }
513515
514 - function getStatus($which="%") {
515 - return true;
516 - }
 516+ function getStatus($which="%") {
 517+ return true;
 518+ }
517519
518 - function maxListLen() {
519 - return 0;
520 - }
 520+ function maxListLen() {
 521+ return 0;
 522+ }
521523
522 - function encodeBlob($b) {
523 - return $b;
524 - }
 524+ function encodeBlob($b) {
 525+ return $b;
 526+ }
525527
526 - function decodeBlob($b) {
527 - return $b;
528 - }
 528+ function decodeBlob($b) {
 529+ return $b;
 530+ }
529531
530 - public function setTimeout( $timeout ) {
531 - }
 532+ public function setTimeout( $timeout ) {
 533+ }
532534
533 - function sourceFile( $filename, $lineCallback = false, $resultCallback = false ) {
534 - return null;
535 - }
 535+ function sourceFile( $filename, $lineCallback = false, $resultCallback = false ) {
 536+ return null;
 537+ }
536538
537 - function sourceStream( $fp, $lineCallback = false, $resultCallback = false ) {
538 - return true;
539 - }
 539+ function sourceStream( $fp, $lineCallback = false, $resultCallback = false ) {
 540+ return true;
 541+ }
540542
541543
542 - protected function replaceVars( $ins ) {
543 - return true;
544 - }
 544+ protected function replaceVars( $ins ) {
 545+ return true;
 546+ }
545547
546 - protected function tableNameCallback( $matches ) {
547 - }
 548+ protected function tableNameCallback( $matches ) {
 549+ }
548550
549 - /*
550 - * Build a concatenation list to feed into a SQL query
551 - */
552 - function buildConcat( $stringList ) {
553 - return true;
554 - }
 551+ /*
 552+ * Build a concatenation list to feed into a SQL query
 553+ */
 554+ function buildConcat( $stringList ) {
 555+ return true;
 556+ }
555557 }
Index: trunk/extensions/Offline/Offline.php
@@ -29,16 +29,16 @@
3030
3131 // TODO -> mediawiki:
3232 if ( !$wgDBservers ) {
33 - global $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, $wgDBtype, $wgDebugDumpSql;
34 - $wgDBservers = array(array(
35 - 'host' => $wgDBserver,
36 - 'user' => $wgDBuser,
37 - 'password' => $wgDBpassword,
38 - 'dbname' => $wgDBname,
39 - 'type' => $wgDBtype,
40 - 'load' => 1,
41 - 'flags' => ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT
42 - ));
 33+ global $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, $wgDBtype, $wgDebugDumpSql;
 34+ $wgDBservers = array(array(
 35+ 'host' => $wgDBserver,
 36+ 'user' => $wgDBuser,
 37+ 'password' => $wgDBpassword,
 38+ 'dbname' => $wgDBname,
 39+ 'type' => $wgDBtype,
 40+ 'load' => 1,
 41+ 'flags' => ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT
 42+ ));
4343 }
4444
4545
@@ -46,12 +46,12 @@
4747 // Dump reader will be called through a very single-minded sql api.
4848 //$wgDBservers[] = array( // fixme: you can only do this if your primary db will successfully connect().
4949 $wgDBservers[] = array(
50 - 'dbname' => $wgOfflineWikiPath,
51 - 'type' => 'bz2',
52 - 'load' => 1,
53 - 'host' => false,
54 - 'user' => false,
55 - 'flags' => false,
56 - 'password' => false,
 50+ 'dbname' => $wgOfflineWikiPath,
 51+ 'type' => 'bz2',
 52+ 'load' => 1,
 53+ 'host' => false,
 54+ 'user' => false,
 55+ 'flags' => false,
 56+ 'password' => false,
5757 );
5858 }
Index: trunk/extensions/Offline/SearchBz2.php
@@ -10,97 +10,97 @@
1111 * @ingroup Search
1212 */
1313 class SearchBz2 extends SearchEngine {
14 - var $strictMatching = true;
15 - static $mMinSearchLength;
 14+ var $strictMatching = true;
 15+ static $mMinSearchLength;
1616
17 - function __construct( $db ) {
18 - $this->db = $db;
19 - }
 17+ function __construct( $db ) {
 18+ $this->db = $db;
 19+ }
2020
21 - /**
22 - * Parse the user's query and transform it into an SQL fragment which will
23 - * become part of a WHERE clause
24 - */
25 - function parseQuery( $filteredText, $fulltext ) {
26 - return $filteredText;
27 - }
28 -
29 - /**
30 - * Perform a full text search query and return a result set.
31 - *
32 - * @param $term String: raw search term
33 - * @return MySQLSearchResultSet
34 - */
35 - function searchText( $term ) {
36 - return $this->searchInternal( $term, true );
37 - }
 21+ /**
 22+ * Parse the user's query and transform it into an SQL fragment which will
 23+ * become part of a WHERE clause
 24+ */
 25+ function parseQuery( $filteredText, $fulltext ) {
 26+ return $filteredText;
 27+ }
 28+
 29+ /**
 30+ * Perform a full text search query and return a result set.
 31+ *
 32+ * @param $term String: raw search term
 33+ * @return MySQLSearchResultSet
 34+ */
 35+ function searchText( $term ) {
 36+ return $this->searchInternal( $term, true );
 37+ }
3838
39 - /**
40 - * Perform a title-only search query and return a result set.
41 - *
42 - * @param $term String: raw search term
43 - * @return Bz2SearchResultSet
44 - */
45 - function searchTitle( $term ) {
46 - return $this->searchInternal( $term, false );
47 - }
48 -
49 - protected function searchInternal( $term, $fulltext ) {
50 - global $wgCountTotalSearchHits;
51 -
52 - require_once(dirname(__FILE__).'/DumpReader.php');
53 - $results = DumpReader::index_search($term);
 39+ /**
 40+ * Perform a title-only search query and return a result set.
 41+ *
 42+ * @param $term String: raw search term
 43+ * @return Bz2SearchResultSet
 44+ */
 45+ function searchTitle( $term ) {
 46+ return $this->searchInternal( $term, false );
 47+ }
 48+
 49+ protected function searchInternal( $term, $fulltext ) {
 50+ global $wgCountTotalSearchHits;
 51+
 52+ require_once(dirname(__FILE__).'/DumpReader.php');
 53+ $results = DumpReader::index_search($term);
5454
55 - return new Bz2SearchResultSet( $results, $term);
56 - }
 55+ return new Bz2SearchResultSet( $results, $term);
 56+ }
5757 // TODO
58 -// function queryNamespaces() {
 58+// function queryNamespaces() {
5959 }
6060
6161 /**
6262 * @ingroup Search
6363 */
6464 class Bz2SearchResultSet extends SearchResultSet {
65 - function Bz2SearchResultSet($results, $terms) {
66 - $this->mTotalHits = count($results);
67 - $this->mResultSet = $results;
68 - $this->mTerms = $terms;
69 - }
 65+ function Bz2SearchResultSet($results, $terms) {
 66+ $this->mTotalHits = count($results);
 67+ $this->mResultSet = $results;
 68+ $this->mTerms = $terms;
 69+ }
7070
71 - function termMatches() {
72 - return $this->mTerms;
73 - }
 71+ function termMatches() {
 72+ return $this->mTerms;
 73+ }
7474
75 - function numRows() {
76 - return $this->getTotalHits();
77 - }
 75+ function numRows() {
 76+ return $this->getTotalHits();
 77+ }
7878
79 - function getTotalHits() {
80 - return $this->mTotalHits;
81 - }
 79+ function getTotalHits() {
 80+ return $this->mTotalHits;
 81+ }
8282
83 - function next() {
84 - if ($this->mResultSet === false || count($this->mResultSet) < 1)
85 - return false;
 83+ function next() {
 84+ if ($this->mResultSet === false || count($this->mResultSet) < 1)
 85+ return false;
8686
87 - $result = array_pop($this->mResultSet);
88 - if ($result === false)
89 - return false;
 87+ $result = array_pop($this->mResultSet);
 88+ if ($result === false)
 89+ return false;
9090
91 - list ($bzfile, $offset, $title) = $result;
 91+ list ($bzfile, $offset, $title) = $result;
9292
93 - $matches = array();
94 - $row = new stdClass();
95 - if (preg_match('/([^:]*):([^:]+)$/', $title, $matches)) {
 93+ $matches = array();
 94+ $row = new stdClass();
 95+ if (preg_match('/([^:]*):([^:]+)$/', $title, $matches)) {
9696 //TODO lookup index
97 - $row->page_namespace = $matches[1];
98 - $row->page_title = $matches[2];
99 - } else {
100 - $row->page_namespace = NS_MAIN;
101 - $row->page_title = $title;
102 - }
 97+ $row->page_namespace = $matches[1];
 98+ $row->page_title = $matches[2];
 99+ } else {
 100+ $row->page_namespace = NS_MAIN;
 101+ $row->page_title = $title;
 102+ }
103103
104104 //wfDebug('GOT'.$row->page_namespace .' : '. $row->page_title .'('.$bzfile.')');
105 - return new SearchResult($row);
106 - }
 105+ return new SearchResult($row);
 106+ }
107107 }
Index: trunk/extensions/Offline/SpecialOffline.php
@@ -14,7 +14,7 @@
1515 'url' => 'http://code.google.com/p/wikipedia-offline-patch',
1616 'version' => '0.6',
1717 'descriptionmsg' => 'offline_special_desc'
18 - );
 18+);
1919
2020 $dir = dirname(__FILE__);
2121 $wgExtensionMessagesFiles['SpecialOffline'] = $dir.'/SpecialOffline.i18n.php';
@@ -22,145 +22,145 @@
2323 class SpecialOffline extends SpecialPage
2424 {
2525 function SpecialOffline() {
26 - parent::__construct('offline' /*, 'editinterface' */);
 26+ parent::__construct('offline' /*, 'editinterface' */);
2727 }
2828
2929 function execute($param) {
30 - global $wgOut, $wgTitle;
 30+ global $wgOut, $wgTitle;
3131
32 - require_once(dirname(__FILE__).'/DumpReader.php');
 32+ require_once(dirname(__FILE__).'/DumpReader.php');
3333
34 - $this->setHeaders();
35 - $this->outputHeader();
 34+ $this->setHeaders();
 35+ $this->outputHeader();
3636
37 - $this->runTests();
 37+ $this->runTests();
3838
39 - //TODO report and explain wgOfflineIgnoreLiveData
 39+ //TODO report and explain wgOfflineIgnoreLiveData
4040 }
4141
4242 function runTests() {
43 - global $wgOut, $wgTitle;
 43+ global $wgOut, $wgTitle;
4444
45 - $wgOut->wrapWikiMsg('<h1>$1</h1>', 'offline_heading_status');
 45+ $wgOut->wrapWikiMsg('<h1>$1</h1>', 'offline_heading_status');
4646
47 - $wgOut->addHTML('<ul>');
48 - // lookup a real article in the index can be searched
49 - $results = DumpReader::index_search(wfMsg('offline_test_article'));
50 - if (count($results) > 0)
51 - list ($bz_file, $offset, $entry_title) = $results[0];
 47+ $wgOut->addHTML('<ul>');
 48+ // lookup a real article in the index can be searched
 49+ $results = DumpReader::index_search(wfMsg('offline_test_article'));
 50+ if (count($results) > 0)
 51+ list ($bz_file, $offset, $entry_title) = $results[0];
5252
53 - $test_index = isset($bz_file);
54 - $this->printTest($test_index, 'offline_index_test');
55 - if (!$test_index) {
56 - $this->diagnoseIndex();
57 - return;
58 - }
 53+ $test_index = isset($bz_file);
 54+ $this->printTest($test_index, 'offline_index_test');
 55+ if (!$test_index) {
 56+ $this->diagnoseIndex();
 57+ return;
 58+ }
5959
60 - // tests that bz2 dumpfiles can be opened and read
61 - $xml = DumpReader::load_bz($bz_file, $entry_title);
62 - $test_bz = isset($xml);
63 - $this->printTest($test_bz, 'offline_bzload_test');
64 - if (!$test_bz) {
65 - $this->diagnoseBzload($bz_file);
66 - return;
67 - }
68 - //report subdirectory setting
69 -// if (substr($bz_file, 0, 1) == 'x') {
70 -// $subdir = dirname($bz_file); //TODO strip absolute components if needed
71 -// $wgOut->addWikiMsg('offline_subdir-status', $subdir);
72 -// $wgOut->addHTML(
73 -// '<label>' . wfMsg('offline_change-subdir') .
74 -// '<input type=text size=20 name="subdir" value="'.$subdir.'">
75 -// <input type=submit name="subdir" value="Change">
76 -// </label/>'
77 -// );
78 -// }
 60+ // tests that bz2 dumpfiles can be opened and read
 61+ $xml = DumpReader::load_bz($bz_file, $entry_title);
 62+ $test_bz = isset($xml);
 63+ $this->printTest($test_bz, 'offline_bzload_test');
 64+ if (!$test_bz) {
 65+ $this->diagnoseBzload($bz_file);
 66+ return;
 67+ }
 68+ //report subdirectory setting
 69+// if (substr($bz_file, 0, 1) == 'x') {
 70+// $subdir = dirname($bz_file); //TODO strip absolute components if needed
 71+// $wgOut->addWikiMsg('offline_subdir-status', $subdir);
 72+// $wgOut->addHTML(
 73+// '<label>' . wfMsg('offline_change-subdir') .
 74+// '<input type=text size=20 name="subdir" value="'.$subdir.'">
 75+// <input type=submit name="subdir" value="Change">
 76+// </label/>'
 77+// );
 78+// }
7979
80 - // TODO report language settings and availabilities
 80+ // TODO report language settings and availabilities
8181
82 - //test that a specific article can be loaded
83 - $article_wml = DumpReader::load_article($entry_title);
84 - $test_article = isset($article_wml);
85 - $this->printTest($test_article, 'offline_article_test');
86 - if (!$test_article) {
87 - //TODO diagnose
88 - return;
89 - }
90 - //TODO test that the wml has not been padded or truncated
 82+ //test that a specific article can be loaded
 83+ $article_wml = DumpReader::load_article($entry_title);
 84+ $test_article = isset($article_wml);
 85+ $this->printTest($test_article, 'offline_article_test');
 86+ if (!$test_article) {
 87+ //TODO diagnose
 88+ return;
 89+ }
 90+ //TODO test that the wml has not been padded or truncated
9191
92 - //test that our handler is still hooked in
93 - $mw_api_article = new Article(Title::newFromText($entry_title));
94 - $mw_api_article->loadContent();
95 - $content = $mw_api_article->getContent();
 92+ //test that our handler is still hooked in
 93+ $mw_api_article = new Article(Title::newFromText($entry_title));
 94+ $mw_api_article->loadContent();
 95+ $content = $mw_api_article->getContent();
9696 //wfDebug('got '.strlen($mw_api_article->mContent).' bytes of wml from cache');
97 - $test_hooks = $mw_api_article->mContentLoaded;
98 - // TODO false positive
99 - $this->printTest($test_hooks, 'offline_hooks_test');
100 - if (!$test_hooks) {
101 - $this->diagnoseHooks();
102 - return;
103 - }
 97+ $test_hooks = $mw_api_article->mContentLoaded;
 98+ // TODO false positive
 99+ $this->printTest($test_hooks, 'offline_hooks_test');
 100+ if (!$test_hooks) {
 101+ $this->diagnoseHooks();
 102+ return;
 103+ }
104104
105 - //TODO test Templates
 105+ //TODO test Templates
106106
107 - $wgOut->addHTML('</ul>');
 107+ $wgOut->addHTML('</ul>');
108108
109 - $wgOut->wrapWikiMsg('<i>$1</i>', 'offline_all_tests_pass');
110 - //TODO div collapse or load on demand
111 - //$wgOut->addWikiText($content);
 109+ $wgOut->wrapWikiMsg('<i>$1</i>', 'offline_all_tests_pass');
 110+ //TODO div collapse or load on demand
 111+ //$wgOut->addWikiText($content);
112112 }
113113
114114 function diagnoseIndex() {
115 - global $wgOut, $wgOfflineWikiPath;
 115+ global $wgOut, $wgOfflineWikiPath;
116116
117 - if (!isset($wgOfflineWikiPath)) {
118 - $this->printDiagnostic('offlinewikipath_not_configured');
119 - }
120 - elseif (!is_dir($wgOfflineWikiPath)) {
121 - $this->printDiagnostic(array('offlinewikipath_not_found', $wgOfflineWikiPath));
122 - }
123 - elseif (!is_dir("$wgOfflineWikiPath/db") || !file_exists("$wgOfflineWikiPath/db/termlist.DB")) {
124 - $this->printDiagnostic(array('offline_dbdir_not_found', $wgOfflineWikiPath));
125 - } else {
126 - $this->printDiagnostic('offline_unknown_index_error');
127 - }
 117+ if (!isset($wgOfflineWikiPath)) {
 118+ $this->printDiagnostic('offlinewikipath_not_configured');
 119+ }
 120+ elseif (!is_dir($wgOfflineWikiPath)) {
 121+ $this->printDiagnostic(array('offlinewikipath_not_found', $wgOfflineWikiPath));
 122+ }
 123+ elseif (!is_dir("$wgOfflineWikiPath/db") || !file_exists("$wgOfflineWikiPath/db/termlist.DB")) {
 124+ $this->printDiagnostic(array('offline_dbdir_not_found', $wgOfflineWikiPath));
 125+ } else {
 126+ $this->printDiagnostic('offline_unknown_index_error');
 127+ }
128128 }
129129
130130 function diagnoseBzload($bz_file) {
131 - global $wgOut, $wgOfflineWikiPath;
132 -
133 - $full_path = $wgOfflineWikiPath.'/'.$bz_file;
134 - if (!extension_loaded('bz2')) {
135 - $this->printDiagnostic('offline_bz2_ext_needed');
136 - }
137 - if (!file_exists($full_path)) {
138 - $this->printDiagnostic(array('offline_bz2_file_gone', $full_path));
139 - }
140 - else {
141 - $this->printDiagnostic(array('offline_unknown_bz2_error', $full_path));
142 - }
 131+ global $wgOut, $wgOfflineWikiPath;
 132+
 133+ $full_path = $wgOfflineWikiPath.'/'.$bz_file;
 134+ if (!extension_loaded('bz2')) {
 135+ $this->printDiagnostic('offline_bz2_ext_needed');
 136+ }
 137+ if (!file_exists($full_path)) {
 138+ $this->printDiagnostic(array('offline_bz2_file_gone', $full_path));
 139+ }
 140+ else {
 141+ $this->printDiagnostic(array('offline_unknown_bz2_error', $full_path));
 142+ }
143143 }
144144
145145 function diagnoseHooks() {
146 - global $wgOut, $wgMemc;
147 - $key = wfMemcKey('offline','trial');
148 - $wgMemc->set($key, true);
149 - if (!$wgMemc->get($key)) {
150 - $this->printDiagnostic('offline_cache_needed');
151 - }
152 - // check that passing revisiontext through cache will work
 146+ global $wgOut, $wgMemc;
 147+ $key = wfMemcKey('offline','trial');
 148+ $wgMemc->set($key, true);
 149+ if (!$wgMemc->get($key)) {
 150+ $this->printDiagnostic('offline_cache_needed');
 151+ }
 152+ // check that passing revisiontext through cache will work
153153 }
154154
155155 function printTest($bool, $msg) {
156 - global $wgOut;
157 - if ($bool)
158 - $wgOut->wrapWikiMsg('<div class="result-pass"><li>$1</div>', $msg.'_pass');
159 - else
160 - $wgOut->wrapWikiMsg('<div class="error"><li>$1</div>', $msg.'_fail');
 156+ global $wgOut;
 157+ if ($bool)
 158+ $wgOut->wrapWikiMsg('<div class="result-pass"><li>$1</div>', $msg.'_pass');
 159+ else
 160+ $wgOut->wrapWikiMsg('<div class="error"><li>$1</div>', $msg.'_fail');
161161 }
162162
163163 function printDiagnostic($msg) {
164 - global $wgOut;
165 - $wgOut->wrapWikiMsg('<div class="errorbox">$1</div>', $msg);
 164+ global $wgOut;
 165+ $wgOut->wrapWikiMsg('<div class="errorbox">$1</div>', $msg);
166166 }
167167 }
Index: trunk/extensions/Offline/DumpReader.php
@@ -9,13 +9,13 @@
1010 $article_wml = null;
1111 $results = self::index_search($title);
1212 if (count($results) > 0) {
13 - $archive_file = $results[0][0];
14 - $plaintext_offset = $results[0][1];
15 - $title = $results[0][2];
 13+ $archive_file = $results[0][0];
 14+ $plaintext_offset = $results[0][1];
 15+ $title = $results[0][2];
1616
17 - $article_wml = self::load_all_data($title, $archive_file);
 17+ $article_wml = self::load_all_data($title, $archive_file);
1818 } else {
19 - $article_wml = ""; //TODO or null?
 19+ $article_wml = ""; //TODO or null?
2020 }
2121 $article_wml = htmlspecialchars_decode($article_wml);
2222 return $article_wml;
@@ -28,21 +28,21 @@
2929 $matches = array();
3030 $all_chunk_data = self::load_bz($file_name);
3131 if (preg_match("/<title>".preg_quote($title, '/')."<\/title>.*?<text[^>]*>(.*)/s",
32 - $all_chunk_data, $matches))
 32+ $all_chunk_data, $matches))
3333 {
34 - $all_chunk_data = $matches[1];
35 - while (isset($all_chunk_data)) {
36 - $end_pos = strpos($all_chunk_data, '</text>');
37 - if ($end_pos !== FALSE) {
38 - $article_wml .= substr($all_chunk_data, 0, $end_pos);
39 - break;
40 - }
41 - $article_wml .= $all_chunk_data;
 34+ $all_chunk_data = $matches[1];
 35+ while (isset($all_chunk_data)) {
 36+ $end_pos = strpos($all_chunk_data, '</text>');
 37+ if ($end_pos !== FALSE) {
 38+ $article_wml .= substr($all_chunk_data, 0, $end_pos);
 39+ break;
 40+ }
 41+ $article_wml .= $all_chunk_data;
4242
43 - wfDebug('continuing into next bz2 chunk');
44 - $file_name = self::increment_file($file_name);
45 - $all_chunk_data = self::load_bz($file_name);
46 - }
 43+ wfDebug('continuing into next bz2 chunk');
 44+ $file_name = self::increment_file($file_name);
 45+ $all_chunk_data = self::load_bz($file_name);
 46+ }
4747 }
4848 return $article_wml;
4949 }
@@ -61,7 +61,7 @@
6262
6363 $out = "";
6464 while ($bz && !feof($bz)) {
65 - $out .= bzread($bz, 8192);
 65+ $out .= bzread($bz, 8192);
6666 }
6767 bzclose($bz);
6868 return $out;
@@ -91,21 +91,21 @@
9292 $matches = $enquire->get_mset(0, 25);
9393
9494 if (0 /*SCORING*/) {
95 - $scores = array();
96 - for ($i = $matches->begin(); !$i->equals($matches->end()); $i->next())
97 - {
98 - $row = $i->get_document();
99 - $str = $i->get_percent()."% [".$row->get_data()."]";
100 - $scores[] = $str;
101 - if (1/*DEBUG*/) wfDebug("$str\n");
102 - }
 95+ $scores = array();
 96+ for ($i = $matches->begin(); !$i->equals($matches->end()); $i->next())
 97+ {
 98+ $row = $i->get_document();
 99+ $str = $i->get_percent()."% [".$row->get_data()."]";
 100+ $scores[] = $str;
 101+ if (1/*DEBUG*/) wfDebug("$str\n");
 102+ }
103103 }
104104
105105 $result = array();
106106 for ($i = $matches->begin(); !$i->equals($matches->end()); $i->next())
107 - {
108 - $entry = $i->get_document()->get_data();
109 - $result[] = explode(':', $entry, 3);
 107+ {
 108+ $entry = $i->get_document()->get_data();
 109+ $result[] = explode(':', $entry, 3);
110110 }
111111 # not in Xapian 1.0.X
112112 #$db->close();
@@ -113,8 +113,8 @@
114114 return $result;
115115
116116 } catch (Exception $e) {
117 - wfDebug(__METHOD__.':'.$e->getMessage());
118 - return null;
 117+ wfDebug(__METHOD__.':'.$e->getMessage());
 118+ return null;
119119 }
120120 }
121121
@@ -124,11 +124,11 @@
125125 $matches = array();
126126 // TODO fails on 99 ...
127127 if (preg_match('/(.*?)([1-9][0-9]*)(.*?)$/', $fname, $matches)) {
128 - $i = $matches[2];
129 - return preg_replace("/$i/", $i + 1, $fname);
 128+ $i = $matches[2];
 129+ return preg_replace("/$i/", $i + 1, $fname);
130130 } else {
131 - wfDebug('Failed to grok your wiki-splits filename pattern');
132 - return false;
 131+ wfDebug('Failed to grok your wiki-splits filename pattern');
 132+ return false;
133133 }
134134 }
135135 }

Comments

#Comment by Nikerabbit (talk | contribs)   09:52, 6 January 2012

The ruling practice is to use tabs for indentation.

Status & tagging log