From ba0fc4fa20067528effd4802e53ceeb959640825 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 12 Jan 2012 13:42:29 +0100 Subject: Update to MediaWiki 1.18.1 --- maintenance/Maintenance.php | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'maintenance/Maintenance.php') diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 9ea57f4e..3618515a 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -32,15 +32,6 @@ if ( !function_exists( 'version_compare' ) || version_compare( PHP_VERSION, '5.2 wfPHPVersionError( 'cli' ); } -// Wrapper for posix_isatty() -if ( !function_exists( 'posix_isatty' ) ) { - # We default as considering stdin a tty (for nice readline methods) - # but treating stout as not a tty to avoid color codes - function posix_isatty( $fd ) { - return !$fd; - } -} - /** * Abstract maintenance class for quickly writing and churning out * maintenance scripts with minimal effort. All that _must_ be defined @@ -1203,6 +1194,22 @@ abstract class Maintenance { return $title; } + /** + * Wrapper for posix_isatty() + * We default as considering stdin a tty (for nice readline methods) + * but treating stout as not a tty to avoid color codes + * + * @param $fd int File descriptor + * @return bool + */ + public static function posix_isatty( $fd ) { + if ( !MWInit::functionExists( 'posix_isatty' ) ) { + return !$fd; + } else { + return posix_isatty( $fd ); + } +} + /** * Prompt the console for input * @param $prompt String what to begin the line with, like '> ' @@ -1211,7 +1218,7 @@ abstract class Maintenance { public static function readconsole( $prompt = '> ' ) { static $isatty = null; if ( is_null( $isatty ) ) { - $isatty = posix_isatty( 0 /*STDIN*/ ); + $isatty = self::posix_isatty( 0 /*STDIN*/ ); } if ( $isatty && function_exists( 'readline' ) ) { -- cgit v1.2.2