Merge "SpecialPasswordReset: Use Config instead of globals"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 4 Aug 2014 09:47:28 +0000 (09:47 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 4 Aug 2014 09:47:28 +0000 (09:47 +0000)
includes/User.php
includes/specials/SpecialJavaScriptTest.php
includes/specials/SpecialProtectedpages.php
tests/phpunit/phpunit.php

index a21119a..7edd93e 100644 (file)
@@ -181,8 +181,16 @@ class User implements IDBAccessObject {
 
        public $mRealName;
 
+       /**
+        * @todo Make this actually private
+        * @private
+        */
        public $mPassword;
 
+       /**
+        * @todo Make this actually private
+        * @private
+        */
        public $mNewpassword;
 
        public $mNewpassTime;
@@ -2247,6 +2255,26 @@ class User implements IDBAccessObject {
                return $this->mTouched;
        }
 
+       /**
+        * @return Password
+        * @since 1.24
+        */
+       public function getPassword() {
+               $this->loadPasswords();
+
+               return $this->mPassword;
+       }
+
+       /**
+        * @return Password
+        * @since 1.24
+        */
+       public function getTemporaryPassword() {
+               $this->loadPasswords();
+
+               return $this->mNewpassword;
+       }
+
        /**
         * Set the password and reset the random token.
         * Calls through to authentication plugin if necessary;
index a67d3c0..0efebb3 100644 (file)
@@ -134,16 +134,15 @@ class SpecialJavaScriptTest extends SpecialPage {
         * Initialize the page for QUnit.
         */
        private function initQUnitTesting() {
-               global $wgJavaScriptTestConfig;
-
                $out = $this->getOutput();
+               $testConfig = $this->getConfig()->get( 'JavaScriptTestConfig' );
 
                $out->addModules( 'test.mediawiki.qunit.testrunner' );
                $qunitTestModules = $out->getResourceLoader()->getTestModuleNames( 'qunit' );
                $out->addModules( $qunitTestModules );
 
                $summary = $this->msg( 'javascripttest-qunit-intro' )
-                       ->params( $wgJavaScriptTestConfig['qunit']['documentation'] )
+                       ->params( $testConfig['qunit']['documentation'] )
                        ->parseAsBlock();
                $header = $this->msg( 'javascripttest-qunit-heading' )->escaped();
                $userDir = $this->getLanguage()->getDir();
@@ -169,7 +168,7 @@ HTML;
                // $wgJavaScriptTestConfig in DefaultSettings.php
                $out->addJsConfigVars(
                        'QUnitTestSwarmInjectJSPath',
-                       $wgJavaScriptTestConfig['qunit']['testswarm-injectjs']
+                       $testConfig['qunit']['testswarm-injectjs']
                );
        }
 
index 7554e37..b64b029 100644 (file)
@@ -103,11 +103,9 @@ class SpecialProtectedpages extends SpecialPage {
        protected function showOptions( $namespace, $type = 'edit', $level, $sizetype,
                $size, $indefOnly, $cascadeOnly, $noRedirect
        ) {
-               global $wgScript;
-
                $title = $this->getPageTitle();
 
-               return Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
+               return Xml::openElement( 'form', array( 'method' => 'get', 'action' => wfScript() ) ) .
                        Xml::openElement( 'fieldset' ) .
                        Xml::element( 'legend', array(), $this->msg( 'protectedpages' )->text() ) .
                        Html::hidden( 'title', $title->getPrefixedDBkey() ) . "\n" .
@@ -252,14 +250,12 @@ class SpecialProtectedpages extends SpecialPage {
         * @return string Formatted HTML
         */
        protected function getLevelMenu( $pr_level ) {
-               global $wgRestrictionLevels;
-
                // Temporary array
                $m = array( $this->msg( 'restriction-level-all' )->text() => 0 );
                $options = array();
 
                // First pass to load the log names
-               foreach ( $wgRestrictionLevels as $type ) {
+               foreach ( $this->getConfig()->get( 'RestrictionLevels' ) as $type ) {
                        // Messages used can be 'restriction-level-sysop' and 'restriction-level-autoconfirmed'
                        if ( $type != '' && $type != '*' ) {
                                $text = $this->msg( "restriction-level-$type" )->text();
index 7dd932f..63313cf 100755 (executable)
@@ -198,36 +198,36 @@ class PHPUnitMaintClass extends Maintenance {
 $maintClass = 'PHPUnitMaintClass';
 require RUN_MAINTENANCE_IF_MAIN;
 
-$pharFile = stream_resolve_include_path( 'phpunit.phar' );
-$isValidPhar = Phar::isValidPharFilename( $pharFile );
-
-if ( !$isValidPhar && !class_exists( 'PHPUnit_Runner_Version' ) ) {
-       // try loading phpunit via PEAR
-       require_once 'PHPUnit/Runner/Version.php';
-}
-
 // Prevent segfault when we have lots of unit tests (bug 62623)
-if ( version_compare( PHP_VERSION, '5.4.0', '<' )
-       && version_compare( PHP_VERSION, '5.3.0', '>=' )
-) {
+if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
        register_shutdown_function( function () {
                gc_collect_cycles();
                gc_disable();
        } );
 }
 
-if ( $isValidPhar ) {
-       require $pharFile;
-} else {
-       if ( PHPUnit_Runner_Version::id() !== '@package_version@'
-           && version_compare( PHPUnit_Runner_Version::id(), '3.7.0', '<' )
-       ) {
-           die( 'PHPUnit 3.7.0 or later required, you have ' . PHPUnit_Runner_Version::id() . ".\n" );
-       }
 
-       if ( !class_exists( 'PHPUnit_TextUI_Command' ) ) {
-           require_once 'PHPUnit/Autoload.php';
+$ok = false;
+
+foreach( array(
+       stream_resolve_include_path( 'phpunit.phar' ),
+       'PHPUnit/Runner/Version.php',
+       'PHPUnit/Autoload.php'
+) as $includePath ) {
+       @include_once( $includePath );
+       if ( class_exists( 'PHPUnit_TextUI_Command' ) ) {
+               $ok = true;
+               break;
        }
+}
+
+if ( !$ok ) {
+       die( "Couldn't find a usable PHPUnit.\n" );
+}
 
-       PHPUnit_TextUI_Command::main();
+$puVersion = PHPUnit_Runner_Version::id();
+if ( $puVersion !== '@package_version@' && version_compare( $puVersion, '3.7.0', '<' ) ) {
+       die( "PHPUnit 3.7.0 or later required; you have {$puVersion}.\n" );
 }
+
+PHPUnit_TextUI_Command::main();