Index: branches/REL1_18/phase3/maintenance/importDump.php |
— | — | @@ -228,7 +228,7 @@ |
229 | 229 | |
230 | 230 | function importFromStdin() { |
231 | 231 | $file = fopen( 'php://stdin', 'rt' ); |
232 | | - if( posix_isatty( $file ) ) { |
| 232 | + if( self::posix_isatty( $file ) ) { |
233 | 233 | $this->maybeHelp( true ); |
234 | 234 | } |
235 | 235 | return $this->importFromHandle( $file ); |
Index: branches/REL1_18/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 |
— | — | @@ -1204,6 +1195,22 @@ |
1205 | 1196 | } |
1206 | 1197 | |
1207 | 1198 | /** |
| 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 | + /** |
1208 | 1215 | * Prompt the console for input |
1209 | 1216 | * @param $prompt String what to begin the line with, like '> ' |
1210 | 1217 | * @return String response |
— | — | @@ -1211,7 +1218,7 @@ |
1212 | 1219 | public static function readconsole( $prompt = '> ' ) { |
1213 | 1220 | static $isatty = null; |
1214 | 1221 | if ( is_null( $isatty ) ) { |
1215 | | - $isatty = posix_isatty( 0 /*STDIN*/ ); |
| 1222 | + $isatty = self::posix_isatty( 0 /*STDIN*/ ); |
1216 | 1223 | } |
1217 | 1224 | |
1218 | 1225 | if ( $isatty && function_exists( 'readline' ) ) { |
Property changes on: branches/REL1_18/phase3/maintenance/Maintenance.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
1219 | 1226 | Merged /trunk/phase3/maintenance/Maintenance.php:r93789 |
Index: branches/REL1_18/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: branches/REL1_18/phase3/RELEASE-NOTES-1.18 |
— | — | @@ -25,6 +25,8 @@ |
26 | 26 | not showing their values on preview. |
27 | 27 | * (bug 32702) Removed method Skin::makeGlobalVariablesScript() has been readded |
28 | 28 | 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(). |
29 | 31 | |
30 | 32 | == MediaWiki 1.18 == |
31 | 33 | 2011-11-24 |
Index: branches/REL1_18/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'] ) { |
Property changes on: branches/REL1_18/phase3/tests/parser/parserTest.inc |
___________________________________________________________________ |
Modified: svn:mergeinfo |
86 | 86 | Merged /trunk/phase3/tests/parser/parserTest.inc:r93789 |
Property changes on: branches/REL1_18/phase3 |
___________________________________________________________________ |
Modified: svn:mergeinfo |
87 | 87 | Merged /trunk/phase3:r93789 |