X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FMaintenance.php;h=d37b990b2d5ded41b35ce4aed7dd2c3dbb08a23a;hb=dac20d0ffab5a850563d3fb02331a927e42a2bd9;hp=89e8089fbfb3abd23d4e26c1db2831d51eb1d937;hpb=f0bfc9ff60826007e91a0639f9cb0b34593e22a3;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 89e8089fbf..d37b990b2d 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -307,6 +307,17 @@ abstract class Maintenance { return $this->hasArg( $argId ) ? $this->mArgs[$argId] : $default; } + /** + * Returns batch size + * + * @since 1.31 + * + * @return int|null + */ + protected function getBatchSize() { + return $this->mBatchSize; + } + /** * Set the batch size. * @param int $s The number of operations to do in a batch @@ -1244,8 +1255,8 @@ abstract class Maintenance { * This function has the same parameters as wfGetDB() * * @param int $db DB index (DB_REPLICA/DB_MASTER) - * @param array $groups; default: empty array - * @param string|bool $wiki; default: current wiki + * @param array $groups default: empty array + * @param string|bool $wiki default: current wiki * @return IMaintainableDatabase */ protected function getDB( $db, $groups = [], $wiki = false ) { @@ -1416,6 +1427,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 +1481,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 ); @@ -1476,7 +1507,7 @@ abstract class Maintenance { * @return string */ private static function readlineEmulation( $prompt ) { - $bash = Installer::locateExecutableInDefaultPaths( [ 'bash' ] ); + $bash = ExecutableFinder::findInDefaultPaths( 'bash' ); if ( !wfIsWindows() && $bash ) { $retval = false; $encPrompt = wfEscapeShellArg( $prompt );