r84894 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84893‎ | r84894 | r84895 >
Date:03:38, 28 March 2011
Author:dantman
Status:ok
Tags:
Comment:
Followup r81928, make proper use of $this->output instead of echo.
Modified paths:
  • /trunk/phase3/maintenance/resetUserTokens.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/resetUserTokens.php
@@ -30,21 +30,16 @@
3131 parent::__construct();
3232 $this->mDescription = "Reset the user_token of all users on the wiki. Note that this may log some of them out.";
3333 $this->addOption( 'nowarn', "Hides the 5 seconds warning", false, false );
34 - $this->addOption( 'quiet', "Do not print what is happening", false, false );
3534 }
3635
3736 public function execute() {
38 - $nowarn = $this->getOption( 'nowarn' );
39 - $quiet = $this->getOption( 'quiet' );
4037
41 - if ( !$nowarn ) {
42 - echo <<<WARN
43 -The script is about to reset the user_token for ALL USERS in the database.
44 -This may log some of them out and is not necessary unless you believe your
45 -user table has been compromised.
46 -
47 -Abort with control-c in the next five seconds....
48 -WARN;
 38+ if ( !$this->getOption( 'nowarn' ) ) {
 39+ $this->output( "The script is about to reset the user_token for ALL USERS in the database.\n" );
 40+ $this->output( "This may log some of them out and is not necessary unless you believe your\n" );
 41+ $this->output( "user table has been compromised.\n" );
 42+ $this->output( "\n" );
 43+ $this->output( "Abort with control-c in the next five seconds (skip this countdown with --nowarn) ... " );
4944 wfCountDown( 5 );
5045 }
5146
@@ -61,17 +56,13 @@
6257
6358 $username = $user->getName();
6459
65 - if ( !$quiet ) {
66 - echo "Resetting user_token for $username: ";
67 - }
 60+ $this->output( "Resetting user_token for $username: " );
6861
6962 // Change value
7063 $user->setToken();
7164 $user->saveSettings();
7265
73 - if ( !$quiet ) {
74 - echo " OK\n";
75 - }
 66+ $this->output( " OK\n" );
7667
7768 }
7869

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81928Add a new maintenance script to reset the user_token of all users if you thin...dantman02:46, 11 February 2011

Status & tagging log