27require_once __DIR__ .
'/Maintenance.php';
35 parent::__construct();
37 $this->
addDescription(
'Pass through all users and change one of their options.
38The new option is NOT validated.' );
40 $this->
addOption(
'list',
'List available user options and their default value' );
41 $this->
addOption(
'usage',
'Report all options statistics or just one if you specify it' );
42 $this->
addOption(
'old',
'The value to look for',
false,
true );
43 $this->
addOption(
'new',
'Rew value to update users with',
false,
true );
44 $this->
addOption(
'nowarn',
'Hides the 5 seconds warning' );
45 $this->
addOption(
'dry',
'Do not save user settings back to database' );
46 $this->
addArg(
'option name',
'Name of the option to change or provide statistics about',
false );
55 } elseif ( $this->
hasOption(
'usage' ) ) {
75 $maxOpt = max( $maxOpt, strlen(
$opt ) );
86 $option = $this->
getArg( 0 );
93 $result =
$dbr->select(
'user',
99 foreach ( $result as $id ) {
104 if ( !array_key_exists( $option, $defaultOptions ) ) {
105 $this->
fatalError(
"Invalid user option. Use --list to see valid choices\n" );
108 $userValue = $user->getOption( $option );
109 if ( $userValue <> $defaultOptions[$option] ) {
111 @
$ret[$option][$userValue]++;
115 foreach ( $defaultOptions as $name => $defaultValue ) {
116 $userValue = $user->getOption( $name );
117 if ( $userValue != $defaultValue ) {
125 foreach (
$ret as $optionName => $usageStats ) {
126 $this->
output(
"Usage for <$optionName> (default: '{$defaultOptions[$optionName]}'):\n" );
127 foreach ( $usageStats as
$value => $count ) {
128 $this->
output(
" $count user(s): '$value'\n" );
139 $option = $this->
getArg( 0 );
144 $this->
warn( $option, $from, $to );
150 $result =
$dbr->select(
'user',
156 foreach ( $result as $id ) {
159 $curValue = $user->getOption( $option );
162 if ( $curValue == $from ) {
163 $this->
output(
"Setting {$option} for $username from '{$from}' to '{$to}'): " );
166 $user->setOption( $option, $to );
170 $user->saveSettings();
174 $this->
output(
"Not changing '$username' using <{$option}> = '$curValue'\n" );
186 private function warn( $option, $from, $to ) {
192The script is about to change the
options for ALL USERS in the database.
193Users with option <$option> =
'$from' will be
made to use
'$to'.
195Abort with control-
c in the next five seconds....
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable or merely the Work and Derivative Works thereof Contribution shall mean any work of including the original version of the Work and any modifications or additions to that Work or Derivative Works that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner For the purposes of this submitted means any form of or written communication sent to the Licensor or its including but not limited to communication on electronic mailing source code control and issue tracking systems that are managed or on behalf the Licensor for the purpose of discussing and improving the but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as Not a Contribution Contributor shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work Grant of Copyright License Subject to the terms and conditions of this each Contributor hereby grants to You a non no royalty irrevocable copyright license to prepare Derivative Works publicly publicly and distribute the Work and such Derivative Works in Source or Object form Grant of Patent License Subject to the terms and conditions of this each Contributor hereby grants to You a non no royalty have made
type show c for details The hypothetical commands show w and show c should show the appropriate parts of the General Public License Of the commands you use may be called something other than show w and show c
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true)
Add some args that are needed.
hasArg( $argId=0)
Does a given argument exist?
hasOption( $name)
Checks to see if a particular param exists.
countDown( $seconds)
Count down from $seconds to zero on the terminal, with a one-second pause between showing each number...
getArg( $argId=0, $default=null)
Get an argument.
addDescription( $text)
Set the description text.
maybeHelp( $force=false)
Maybe show the help.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
execute()
Do the actual work.
updateOptions()
Change our users options.
warn( $option, $from, $to)
The warning message and countdown.
showUsageStats()
List options usage.
__construct()
Default constructor.
listAvailableOptions()
List default options and their value.
static newFromId( $id)
Static factory method for creation from a given user ID.
static getDefaultOptions()
Combine the language default options with any site-specific options and add the default language vari...
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
this hook is for auditing only or null if authentication failed before getting that far $username
Allows to change the fields on the form that will be generated $name
while(( $__line=Maintenance::readconsole()) !==false) print
require_once RUN_MAINTENANCE_IF_MAIN