dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refreshLinks.php: Fix fatal when using --category parameter
[lhc/web/wiklou.git]
/
maintenance
/
userOptions.inc
diff --git
a/maintenance/userOptions.inc
b/maintenance/userOptions.inc
index
9b8714d
..
01cf3c3
100644
(file)
--- a/
maintenance/userOptions.inc
+++ b/
maintenance/userOptions.inc
@@
-22,8
+22,8
@@
*/
// Options we will use
*/
// Options we will use
-$options =
array( 'list', 'nowarn', 'quiet', 'usage', 'dry' )
;
-$optionsWithArgs =
array( 'old', 'new' )
;
+$options =
[ 'list', 'nowarn', 'quiet', 'usage', 'dry' ]
;
+$optionsWithArgs =
[ 'old', 'new' ]
;
require_once __DIR__ . '/commandLine.inc';
require_once __DIR__ . '/commandLine.inc';
@@
-40,10
+40,14
@@
class UserOptions {
private $mMode, $mReady;
private $mMode, $mReady;
- /** Constructor. Will show usage and exit if script options are not correct */
+ /**
+ * Constructor. Will show usage and exit if script options are not correct
+ * @param array $opts
+ * @param array $args
+ */
function __construct( $opts, $args ) {
if ( !$this->checkOpts( $opts, $args ) ) {
function __construct( $opts, $args ) {
if ( !$this->checkOpts( $opts, $args ) ) {
-
UserOptions
::showUsageAndExit();
+
self
::showUsageAndExit();
} else {
$this->mReady = $this->initializeOpts( $opts, $args );
}
} else {
$this->mReady = $this->initializeOpts( $opts, $args );
}
@@
-78,7
+82,6
@@
class UserOptions {
* @return bool
*/
private function initializeOpts( $opts, $args ) {
* @return bool
*/
private function initializeOpts( $opts, $args ) {
-
$this->mQuick = isset( $opts['nowarn'] );
$this->mQuiet = isset( $opts['quiet'] );
$this->mDry = isset( $opts['dry'] );
$this->mQuick = isset( $opts['nowarn'] );
$this->mQuiet = isset( $opts['quiet'] );
$this->mDry = isset( $opts['dry'] );
@@
-101,7
+104,9
@@
class UserOptions {
return true;
}
return true;
}
- // Dumb stuff to run a mode.
+ /**
+ * Dumb stuff to run a mode.
+ */
public function run() {
if ( !$this->mReady ) {
return false;
public function run() {
if ( !$this->mReady ) {
return false;
@@
-112,11
+117,9
@@
class UserOptions {
return true;
}
return true;
}
- #
- # Modes.
- #
-
- /** List default options and their value */
+ /**
+ * List default options and their value
+ */
private function LISTER() {
$def = User::getDefaultOptions();
ksort( $def );
private function LISTER() {
$def = User::getDefaultOptions();
ksort( $def );
@@
-129,26
+132,26
@@
class UserOptions {
}
}
}
}
- /** List options usage */
+ /**
+ * List options usage
+ */
private function USAGER() {
private function USAGER() {
- $ret =
array()
;
+ $ret =
[]
;
$defaultOptions = User::getDefaultOptions();
$defaultOptions = User::getDefaultOptions();
- // We list user by user_id from one of the
slave database
- $dbr = wfGetDB( DB_
SLAVE
);
+ // We list user by user_id from one of the
replica DBs
+ $dbr = wfGetDB( DB_
REPLICA
);
$result = $dbr->select( 'user',
$result = $dbr->select( 'user',
-
array( 'user_id' )
,
-
array()
,
+
[ 'user_id' ]
,
+
[]
,
__METHOD__
);
foreach ( $result as $id ) {
__METHOD__
);
foreach ( $result as $id ) {
-
$user = User::newFromId( $id->user_id );
// Get the options and update stats
if ( $this->mAnOption ) {
$user = User::newFromId( $id->user_id );
// Get the options and update stats
if ( $this->mAnOption ) {
-
if ( !array_key_exists( $this->mAnOption, $defaultOptions ) ) {
print "Invalid user option. Use --list to see valid choices\n";
exit;
if ( !array_key_exists( $this->mAnOption, $defaultOptions ) ) {
print "Invalid user option. Use --list to see valid choices\n";
exit;
@@
-182,27
+185,27
@@
class UserOptions {
}
}
}
}
- /** Change our users options */
+ /**
+ * Change our users options
+ */
private function CHANGER() {
$this->warn();
private function CHANGER() {
$this->warn();
- // We list user by user_id from one of the
slave database
- $dbr = wfGetDB( DB_
SLAVE
);
+ // We list user by user_id from one of the
replica DBs
+ $dbr = wfGetDB( DB_
REPLICA
);
$result = $dbr->select( 'user',
$result = $dbr->select( 'user',
-
array( 'user_id' )
,
-
array()
,
+
[ 'user_id' ]
,
+
[]
,
__METHOD__
);
foreach ( $result as $id ) {
__METHOD__
);
foreach ( $result as $id ) {
-
$user = User::newFromId( $id->user_id );
$curValue = $user->getOption( $this->mAnOption );
$username = $user->getName();
if ( $curValue == $this->mOldValue ) {
$user = User::newFromId( $id->user_id );
$curValue = $user->getOption( $this->mAnOption );
$username = $user->getName();
if ( $curValue == $this->mOldValue ) {
-
if ( !$this->mQuiet ) {
print "Setting {$this->mAnOption} for $username from '{$this->mOldValue}' " .
"to '{$this->mNewValue}'): ";
if ( !$this->mQuiet ) {
print "Setting {$this->mAnOption} for $username from '{$this->mOldValue}' " .
"to '{$this->mNewValue}'): ";
@@
-230,7
+233,7
@@
class UserOptions {
*/
public static function getDefaultOptionsNames() {
$def = User::getDefaultOptions();
*/
public static function getDefaultOptionsNames() {
$def = User::getDefaultOptions();
- $ret =
array()
;
+ $ret =
[]
;
foreach ( $def as $optname => $defaultValue ) {
array_push( $ret, $optname );
}
foreach ( $def as $optname => $defaultValue ) {
array_push( $ret, $optname );
}
@@
-238,10
+241,6
@@
class UserOptions {
return $ret;
}
return $ret;
}
- #
- # Helper methods
- #
-
public static function showUsageAndExit() {
print <<<USAGE
public static function showUsageAndExit() {
print <<<USAGE
@@
-275,7
+274,6
@@
USAGE;
* @return bool
*/
public function warn() {
* @return bool
*/
public function warn() {
-
if ( $this->mQuick ) {
return true;
}
if ( $this->mQuick ) {
return true;
}