Index: trunk/phase3/maintenance/importDump.php |
— | — | @@ -229,7 +229,7 @@ |
230 | 230 | |
231 | 231 | function importFromStdin() { |
232 | 232 | $file = fopen( 'php://stdin', 'rt' ); |
233 | | - if( posix_isatty( $file ) ) { |
| 233 | + if( self::posix_isatty( $file ) ) { |
234 | 234 | $this->maybeHelp( true ); |
235 | 235 | } |
236 | 236 | return $this->importFromHandle( $file ); |
Index: trunk/phase3/maintenance/eval.php |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | } |
60 | 60 | |
61 | 61 | if ( function_exists( 'readline_add_history' ) |
62 | | - && posix_isatty( 0 /*STDIN*/ ) ) |
| 62 | + && Maintenance::posix_isatty( 0 /*STDIN*/ ) ) |
63 | 63 | { |
64 | 64 | $useReadline = true; |
65 | 65 | } else { |
Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -32,15 +32,6 @@ |
33 | 33 | wfPHPVersionError( 'cli' ); |
34 | 34 | } |
35 | 35 | |
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 | | - |
45 | 36 | /** |
46 | 37 | * Abstract maintenance class for quickly writing and churning out |
47 | 38 | * maintenance scripts with minimal effort. All that _must_ be defined |
— | — | @@ -1195,6 +1186,22 @@ |
1196 | 1187 | } |
1197 | 1188 | |
1198 | 1189 | /** |
| 1190 | + * Wrapper for posix_isatty() |
| 1191 | + * We default as considering stdin a tty (for nice readline methods) |
| 1192 | + * but treating stout as not a tty to avoid color codes |
| 1193 | + * |
| 1194 | + * @param $fd int File descriptor |
| 1195 | + * @return bool |
| 1196 | + */ |
| 1197 | + public static function posix_isatty( $fd ) { |
| 1198 | + if ( !MWInit::functionExists( 'posix_isatty' ) ) { |
| 1199 | + return !$fd; |
| 1200 | + } else { |
| 1201 | + return posix_isatty( $fd ); |
| 1202 | + } |
| 1203 | +} |
| 1204 | + |
| 1205 | + /** |
1199 | 1206 | * Prompt the console for input |
1200 | 1207 | * @param $prompt String what to begin the line with, like '> ' |
1201 | 1208 | * @return String response |
— | — | @@ -1202,7 +1209,7 @@ |
1203 | 1210 | public static function readconsole( $prompt = '> ' ) { |
1204 | 1211 | static $isatty = null; |
1205 | 1212 | if ( is_null( $isatty ) ) { |
1206 | | - $isatty = posix_isatty( 0 /*STDIN*/ ); |
| 1213 | + $isatty = self::posix_isatty( 0 /*STDIN*/ ); |
1207 | 1214 | } |
1208 | 1215 | |
1209 | 1216 | if ( $isatty && function_exists( 'readline' ) ) { |
Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -33,6 +33,8 @@ |
34 | 34 | * (bug 25355) Parser generates edit section links for special pages. |
35 | 35 | * (bug 27894) Move 'editondblclick' event listener down from body to |
36 | 36 | div#bodyContent. |
| 37 | +* (bug 30172) The check for posix_isatty() in maintenance scripts did not detect |
| 38 | + when the function exists but is disabled. Introduced Maintenance::posix_isatty() |
37 | 39 | |
38 | 40 | === API changes in 1.19 === |
39 | 41 | * (bug 19838) siprop=interwikimap can now use the interwiki cache. |
Index: trunk/phase3/tests/parser/parserTest.inc |
— | — | @@ -78,7 +78,7 @@ |
79 | 79 | */ |
80 | 80 | public function __construct( $options = array() ) { |
81 | 81 | # Only colorize output if stdout is a terminal. |
82 | | - $this->color = !wfIsWindows() && posix_isatty( 1 ); |
| 82 | + $this->color = !wfIsWindows() && Maintenance::posix_isatty( 1 ); |
83 | 83 | |
84 | 84 | if ( isset( $options['color'] ) ) { |
85 | 85 | switch( $options['color'] ) { |