jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/383961 )
Change subject: Move wfCountDown() into Maintenance class ...................................................................... Move wfCountDown() into Maintenance class Doing this allows to restrict it to maintenance scripts and support quiet mode. Change-Id: Iad0858ce1fdd64f746d5f9d4a7d6ed96f21e94df --- M RELEASE-NOTES-1.31 M includes/GlobalFunctions.php M maintenance/Maintenance.php M maintenance/resetUserTokens.php M maintenance/update.php 5 files changed, 33 insertions(+), 3 deletions(-) Approvals: Aaron Schulz: Looks good to me, approved jenkins-bot: Verified diff --git a/RELEASE-NOTES-1.31 b/RELEASE-NOTES-1.31 index 57cbec4..efadf9a 100644 --- a/RELEASE-NOTES-1.31 +++ b/RELEASE-NOTES-1.31 @@ -44,6 +44,8 @@ * MessageBlobStore::insertMessageBlob() (deprecated in 1.27) was removed. * The global function wfBCP47 was renamed to LanguageCode::bcp47. * The global function wfBCP47 is now deprecated. +* The global function wfCountDown() is now deprecated in favor of + Maintenance::countDown(). == Compatibility == MediaWiki 1.31 requires PHP 5.5.9 or later. There is experimental support for diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index d53e98d..537a97f 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3047,6 +3047,8 @@ * Count down from $seconds to zero on the terminal, with a one-second pause * between showing each number. For use in command-line scripts. * + * @deprecated since 1.31, use Maintenance::countDown() + * * @codeCoverageIgnore * @param int $seconds */ diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index ecbbb85..9a29055 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -1417,6 +1417,32 @@ } /** + * 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) * but treating stout as not a tty to avoid color codes diff --git a/maintenance/resetUserTokens.php b/maintenance/resetUserTokens.php index 481da98..1c8b4b9 100644 --- a/maintenance/resetUserTokens.php +++ b/maintenance/resetUserTokens.php @@ -64,7 +64,7 @@ $this->output( "\n" ); $this->output( "Abort with control-c in the next five seconds " . "(skip this countdown with --nowarn) ... " ); - wfCountDown( 5 ); + $this->countDown( 5 ); } // We list user by user_id from one of the replica DBs diff --git a/maintenance/update.php b/maintenance/update.php index 5f705ba..5e2947b 100755 --- a/maintenance/update.php +++ b/maintenance/update.php @@ -128,7 +128,7 @@ $this->compatChecks(); } else { $this->output( "Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n" ); - wfCountDown( 5 ); + $this->countDown( 5 ); } // Check external dependencies are up to date @@ -155,7 +155,7 @@ if ( !$this->hasOption( 'quick' ) ) { $this->output( "Abort with control-c in the next five seconds " . "(skip this countdown with --quick) ... " ); - wfCountDown( 5 ); + $this->countDown( 5 ); } $time1 = microtime( true ); -- To view, visit https://gerrit.wikimedia.org/r/383961 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iad0858ce1fdd64f746d5f9d4a7d6ed96f21e94df Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: MaxSem <maxsem.w...@gmail.com> Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits