r107899 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107898‎ | r107899 | r107900 >
Date:17:02, 3 January 2012
Author:reedy
Status:ok
Tags:
Comment:
MFT r93789
Modified paths:
  • /branches/REL1_18/phase3 (modified) (history)
  • /branches/REL1_18/phase3/RELEASE-NOTES-1.18 (modified) (history)
  • /branches/REL1_18/phase3/maintenance/Maintenance.php (modified) (history)
  • /branches/REL1_18/phase3/maintenance/eval.php (modified) (history)
  • /branches/REL1_18/phase3/maintenance/importDump.php (modified) (history)
  • /branches/REL1_18/phase3/tests/parser/parserTest.inc (modified) (history)

Diff [purge]

Index: branches/REL1_18/phase3/maintenance/importDump.php
@@ -228,7 +228,7 @@
229229
230230 function importFromStdin() {
231231 $file = fopen( 'php://stdin', 'rt' );
232 - if( posix_isatty( $file ) ) {
 232+ if( self::posix_isatty( $file ) ) {
233233 $this->maybeHelp( true );
234234 }
235235 return $this->importFromHandle( $file );
Index: branches/REL1_18/phase3/maintenance/Maintenance.php
@@ -32,15 +32,6 @@
3333 wfPHPVersionError( 'cli' );
3434 }
3535
36 -// Wrapper for posix_isatty()
37 -if ( !function_exists( 'posix_isatty' ) ) {
38 - # We default as considering stdin a tty (for nice readline methods)
39 - # but treating stout as not a tty to avoid color codes
40 - function posix_isatty( $fd ) {
41 - return !$fd;
42 - }
43 -}
44 -
4536 /**
4637 * Abstract maintenance class for quickly writing and churning out
4738 * maintenance scripts with minimal effort. All that _must_ be defined
@@ -1204,6 +1195,22 @@
12051196 }
12061197
12071198 /**
 1199+ * Wrapper for posix_isatty()
 1200+ * We default as considering stdin a tty (for nice readline methods)
 1201+ * but treating stout as not a tty to avoid color codes
 1202+ *
 1203+ * @param $fd int File descriptor
 1204+ * @return bool
 1205+ */
 1206+ public static function posix_isatty( $fd ) {
 1207+ if ( !MWInit::functionExists( 'posix_isatty' ) ) {
 1208+ return !$fd;
 1209+ } else {
 1210+ return posix_isatty( $fd );
 1211+ }
 1212+}
 1213+
 1214+ /**
12081215 * Prompt the console for input
12091216 * @param $prompt String what to begin the line with, like '> '
12101217 * @return String response
@@ -1211,7 +1218,7 @@
12121219 public static function readconsole( $prompt = '> ' ) {
12131220 static $isatty = null;
12141221 if ( is_null( $isatty ) ) {
1215 - $isatty = posix_isatty( 0 /*STDIN*/ );
 1222+ $isatty = self::posix_isatty( 0 /*STDIN*/ );
12161223 }
12171224
12181225 if ( $isatty && function_exists( 'readline' ) ) {
Property changes on: branches/REL1_18/phase3/maintenance/Maintenance.php
___________________________________________________________________
Modified: svn:mergeinfo
12191226 Merged /trunk/phase3/maintenance/Maintenance.php:r93789
Index: branches/REL1_18/phase3/maintenance/eval.php
@@ -58,7 +58,7 @@
5959 }
6060
6161 if ( function_exists( 'readline_add_history' )
62 - && posix_isatty( 0 /*STDIN*/ ) )
 62+ && Maintenance::posix_isatty( 0 /*STDIN*/ ) )
6363 {
6464 $useReadline = true;
6565 } else {
Index: branches/REL1_18/phase3/RELEASE-NOTES-1.18
@@ -25,6 +25,8 @@
2626 not showing their values on preview.
2727 * (bug 32702) Removed method Skin::makeGlobalVariablesScript() has been readded
2828 for backward compatibility.
 29+* (bug 30172) The check for posix_isatty() in maintenance scripts did not detect
 30+ when the function exists but is disabled. Introduced Maintenance::posix_isatty().
2931
3032 == MediaWiki 1.18 ==
3133 2011-11-24
Index: branches/REL1_18/phase3/tests/parser/parserTest.inc
@@ -78,7 +78,7 @@
7979 */
8080 public function __construct( $options = array() ) {
8181 # Only colorize output if stdout is a terminal.
82 - $this->color = !wfIsWindows() && posix_isatty( 1 );
 82+ $this->color = !wfIsWindows() && Maintenance::posix_isatty( 1 );
8383
8484 if ( isset( $options['color'] ) ) {
8585 switch( $options['color'] ) {
Property changes on: branches/REL1_18/phase3/tests/parser/parserTest.inc
___________________________________________________________________
Modified: svn:mergeinfo
8686 Merged /trunk/phase3/tests/parser/parserTest.inc:r93789
Property changes on: branches/REL1_18/phase3
___________________________________________________________________
Modified: svn:mergeinfo
8787 Merged /trunk/phase3:r93789

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r93789(bug 30172) posix_isatty() fallback does not work when the function has been ...demon22:01, 2 August 2011

Status & tagging log