From: Antoine Musso Date: Thu, 3 May 2007 17:39:49 +0000 (+0000) Subject: * Add a static function to 'easily' parse options X-Git-Tag: 1.31.0-rc.0~53099 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=e491469d36ffd48116c36882da9526ed6f3220e9;p=lhc%2Fweb%2Fwiklou.git * Add a static function to 'easily' parse options * Add support for wgMaxTocLevel option in parserTests --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index be1caddf40..10e6e80f6c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -34,6 +34,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN == Maintenance script changes since 1.10 == +* Add support for wgMaxTocLevel option in parserTests + == Languages updated since 1.10 == diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index ddf8b89acf..b2dffa7d80 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -327,6 +327,22 @@ class ParserTest { } } + + /** + * Use a regex to find out the value of an option + * @param $regex A regex, the first group will be the value returned + * @param $opts Options line to look in + * @param $defaults Default value returned if the regex does not match + */ + private static function getOptionValue( $regex, $opts, $default ) { + $m = array(); + if( preg_match( $regex, $opts, $m ) ) { + return $m[1]; + } else { + return $default; + } + } + /** * Set up the global variables for a consistent environment for each test. * Ideally this should replace the global configuration entirely. @@ -342,19 +358,13 @@ class ParserTest { $this->uploadDir = $this->setupUploadDir(); } - $m = array(); - if( preg_match( '/language=([a-z]+(?:_[a-z]+)?)/', $opts, $m ) ) { - $lang = $m[1]; - } else { - $lang = 'en'; - } - - if( preg_match( '/variant=([a-z]+(?:-[a-z]+)?)/', $opts, $m ) ) { - $variant = $m[1]; - } else { - $variant = false; - } - + # Find out values for some special options. + $lang = + self::getOptionValue( '/language=([a-z]+(?:_[a-z]+)?)/', $opts, 'en' ); + $variant = + self::getOptionValue( '/variant=([a-z]+(?:-[a-z]+)?)/', $opts, false ); + $maxtoclevel = + self::getOptionValue( '/wgMaxTocLevel=(\d+)/', $opts, 999 ); $settings = array( 'wgServer' => 'http://localhost', @@ -374,7 +384,7 @@ class ParserTest { 'wgLang' => null, 'wgContLang' => null, 'wgNamespacesWithSubpages' => array( 0 => preg_match('/\\bsubpage\\b/i', $opts)), - 'wgMaxTocLevel' => 999, + 'wgMaxTocLevel' => $maxtoclevel, 'wgCapitalLinks' => true, 'wgNoFollowLinks' => true, 'wgThumbnailScriptPath' => false,