r74750 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74749‎ | r74750 | r74751 >
Date:23:52, 13 October 2010
Author:mglaser
Status:ok (Comments)
Tags:
Comment:
* handle PHP 5.2 ini files
* sample ini file for PHP 5.2
* credits to dan nessett
Modified paths:
  • /trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php (modified) (history)
  • /trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.php52.sample (added) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.php52.sample
@@ -0,0 +1,19 @@
 2+[browsers]
 3+
 4+firefox = "*firefox"
 5+iexploreproxy = "*iexploreproxy"
 6+chrome = "*chrome"
 7+
 8+[SeleniumSettings]
 9+
 10+host = "localhost"
 11+port = "4444"
 12+wikiUrl = "http://localhost/mediawiki/latest_trunk/trunk/phase3"
 13+username = "Wikiadmin"
 14+userPassword = "Wikiadminpw"
 15+testBrowser = "firefox"
 16+
 17+[testSuite]
 18+
 19+SimpleSeleniumTestSuite = "maintenance/tests/selenium/SimpleSeleniumTestSuite.php"
 20+PagedTiffHandlerSeleniumTestSuite = "extensions/PagedTiffHandler/selenium/PagedTiffHandlerTestSuite.php"
Index: trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php
@@ -10,6 +10,7 @@
1111 * See sample config file in selenium_settings.ini.sample
1212 *
1313 */
 14+
1415 public static function getSeleniumSettings ( &$seleniumSettings,
1516 &$seleniumBrowsers,
1617 &$seleniumTestSuites,
@@ -23,7 +24,16 @@
2425 throw new MWException( "Unable to read local Selenium Settings from " . $seleniumConfigFile . "\n" );
2526 }
2627
27 - $configArray = parse_ini_file($seleniumConfigFile, true);
 28+ if ( !defined( 'PHP_VERSION_ID' ) ||
 29+ ( PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 3 ) ) {
 30+ $configArray = self::parse_5_2_ini_file( $seleniumConfigFile );
 31+ } else {
 32+ $configArray = parse_ini_file( $seleniumConfigFile, true );
 33+ }
 34+ if ( $configArray === false ) {
 35+ throw new MWException( "Error parsing " . $seleniumConfigFile . "\n" );
 36+ }
 37+
2838 if ( array_key_exists( 'SeleniumSettings', $configArray) ) {
2939 wfSuppressWarnings();
3040 //we may need to change how this is set. But for now leave it in the ini file
@@ -45,4 +55,28 @@
4656 return true;
4757 }
4858
 59+ private static function parse_5_2_ini_file ( $ConfigFile ) {
 60+
 61+ $configArray = parse_ini_file( $ConfigFile, true );
 62+ if ( $configArray === false ) return false;
 63+
 64+ // PHP 5.2 ini files have [browsers] and [testSuite] sections
 65+ // to get around lack of support for array keys. It then
 66+ // inserts the section arrays into the appropriate places in
 67+ // the SeleniumSettings and SeleniumTests arrays.
 68+
 69+ if ( isset( $configArray[browsers] ) ) {
 70+ $configArray[SeleniumSettings][browsers] = $configArray[browsers];
 71+ unset ( $configArray[browsers] );
 72+ }
 73+
 74+ if ( isset( $configArray[testSuite] ) ) {
 75+ $configArray[SeleniumTests][testSuite] = $configArray[testSuite];
 76+ unset ( $configArray[testSuite] );
 77+ }
 78+
 79+ return $configArray;
 80+
 81+ }
 82+
4983 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r75029Follow up r74750, array keys should be stringsmglaser19:38, 19 October 2010

Comments

#Comment by Platonides (talk | contribs)   17:34, 17 October 2010

All of the $configArray keys should be strings, not constants.

#Comment by Mglaser (talk | contribs)   19:39, 19 October 2010

changed that in r75029

Status & tagging log