X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=maintenance%2FMaintenance.php;h=7de0ae4ccbc0202c3d6d2c8a6505fb7fd30f64d2;hp=ecbbb85117f41401b8ac34c68fc7c9273133ac58;hb=128881c1f19a9c5c476822bde821ae898d0c5887;hpb=91be4ee4645e28866910f654c6eda730a692fc90 diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index ecbbb85117..7de0ae4ccb 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -1416,6 +1416,32 @@ abstract class Maintenance { return $title; } + /** + * Count down from $seconds to zero on the terminal, with a one-second pause + * between showing each number. If the maintenance script is in quiet mode, + * this function does nothing. + * + * @since 1.31 + * + * @codeCoverageIgnore + * @param int $seconds + */ + protected function countDown( $seconds ) { + if ( $this->isQuiet() ) { + return; + } + for ( $i = $seconds; $i >= 0; $i-- ) { + if ( $i != $seconds ) { + $this->output( str_repeat( "\x08", strlen( $i + 1 ) ) ); + } + $this->output( $i ); + if ( $i ) { + sleep( 1 ); + } + } + $this->output( "\n" ); + } + /** * Wrapper for posix_isatty() * We default as considering stdin a tty (for nice readline methods) @@ -1444,13 +1470,7 @@ abstract class Maintenance { } if ( $isatty && function_exists( 'readline' ) ) { - $resp = readline( $prompt ); - if ( $resp === null ) { - // Workaround for https://github.com/facebook/hhvm/issues/4776 - return false; - } else { - return $resp; - } + return readline( $prompt ); } else { if ( $isatty ) { $st = self::readlineEmulation( $prompt );