Merge "Rewrite pref cleanup script"
[lhc/web/wiklou.git] / maintenance / Maintenance.php
index 8bfead3..527e6cb 100644 (file)
@@ -182,7 +182,7 @@ abstract class Maintenance {
                if ( $count < 2 ) {
                        return false; // sanity
                }
-               if ( $bt[0]['class'] !== 'Maintenance' || $bt[0]['function'] !== 'shouldExecute' ) {
+               if ( $bt[0]['class'] !== self::class || $bt[0]['function'] !== 'shouldExecute' ) {
                        return false; // last call should be to this function
                }
                $includeFuncs = [ 'require_once', 'require', 'include', 'include_once' ];
@@ -414,7 +414,10 @@ abstract class Maintenance {
                        $this->fatalError( $err, intval( $die ) );
                }
                $this->outputChanneled( false );
-               if ( PHP_SAPI == 'cli' ) {
+               if (
+                       ( PHP_SAPI == 'cli' || PHP_SAPI == 'phpdbg' ) &&
+                       !defined( 'MW_PHPUNIT_TEST' )
+               ) {
                        fwrite( STDERR, $err . "\n" );
                } else {
                        print $err;
@@ -676,7 +679,8 @@ abstract class Maintenance {
                global $IP, $wgCommandLineMode, $wgRequestTime;
 
                # Abort if called from a web server
-               if ( PHP_SAPI !== 'cli' ) {
+               # wfIsCLI() is not available yet
+               if ( PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg' ) {
                        $this->fatalError( 'This script must be run from the command line' );
                }
 
@@ -1206,6 +1210,9 @@ abstract class Maintenance {
                                "must exist and be readable in the source directory.\n" .
                                "Use --conf to specify it." );
                }
+               if ( isset( $this->mOptions['server'] ) ) {
+                       $_SERVER['SERVER_NAME'] = $this->mOptions['server'];
+               }
                $wgCommandLineMode = true;
 
                return $settingsFile;