r21832 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21831‎ | r21832 | r21833 >
Date:17:39, 3 May 2007
Author:hashar
Status:old
Tags:
Comment:
* Add a static function to 'easily' parse options
* Add support for wgMaxTocLevel option in parserTests
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/maintenance/parserTests.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.inc
@@ -327,7 +327,23 @@
328328 }
329329 }
330330
 331+
331332 /**
 333+ * Use a regex to find out the value of an option
 334+ * @param $regex A regex, the first group will be the value returned
 335+ * @param $opts Options line to look in
 336+ * @param $defaults Default value returned if the regex does not match
 337+ */
 338+ private static function getOptionValue( $regex, $opts, $default ) {
 339+ $m = array();
 340+ if( preg_match( $regex, $opts, $m ) ) {
 341+ return $m[1];
 342+ } else {
 343+ return $default;
 344+ }
 345+ }
 346+
 347+ /**
332348 * Set up the global variables for a consistent environment for each test.
333349 * Ideally this should replace the global configuration entirely.
334350 */
@@ -342,20 +358,14 @@
343359 $this->uploadDir = $this->setupUploadDir();
344360 }
345361
346 - $m = array();
347 - if( preg_match( '/language=([a-z]+(?:_[a-z]+)?)/', $opts, $m ) ) {
348 - $lang = $m[1];
349 - } else {
350 - $lang = 'en';
351 - }
 362+ # Find out values for some special options.
 363+ $lang =
 364+ self::getOptionValue( '/language=([a-z]+(?:_[a-z]+)?)/', $opts, 'en' );
 365+ $variant =
 366+ self::getOptionValue( '/variant=([a-z]+(?:-[a-z]+)?)/', $opts, false );
 367+ $maxtoclevel =
 368+ self::getOptionValue( '/wgMaxTocLevel=(\d+)/', $opts, 999 );
352369
353 - if( preg_match( '/variant=([a-z]+(?:-[a-z]+)?)/', $opts, $m ) ) {
354 - $variant = $m[1];
355 - } else {
356 - $variant = false;
357 - }
358 -
359 -
360370 $settings = array(
361371 'wgServer' => 'http://localhost',
362372 'wgScript' => '/index.php',
@@ -374,7 +384,7 @@
375385 'wgLang' => null,
376386 'wgContLang' => null,
377387 'wgNamespacesWithSubpages' => array( 0 => preg_match('/\\bsubpage\\b/i', $opts)),
378 - 'wgMaxTocLevel' => 999,
 388+ 'wgMaxTocLevel' => $maxtoclevel,
379389 'wgCapitalLinks' => true,
380390 'wgNoFollowLinks' => true,
381391 'wgThumbnailScriptPath' => false,
Index: trunk/phase3/RELEASE-NOTES
@@ -34,7 +34,9 @@
3535
3636 == Maintenance script changes since 1.10 ==
3737
 38+* Add support for wgMaxTocLevel option in parserTests
3839
 40+
3941 == Languages updated since 1.10 ==
4042
4143 * Arabic (ar)