7require_once __DIR__ .
'/Maintenance.php';
22 parent::__construct();
25 'Name of the user preference to initialize',
32 'Name of the user preference to take the value from',
43 $this->
output(
"Initializing '$target' based on the value of '$source'\n" );
50 $dbr->newSelectQueryBuilder()
51 ->from(
'user_properties' )
52 ->select( [
'up_user',
'up_value' ] )
55 $dbr->expr(
'up_value',
'!=',
null ),
56 $dbr->expr(
'up_value',
'!=',
'0' ),
58 ->caller( __METHOD__ ),
59 [
'up_user',
'up_property' ],
64 foreach ( $iterator as $batch ) {
65 foreach ( $batch as $row ) {
66 $dbw->newInsertQueryBuilder()
67 ->insertInto(
'user_properties' )
69 'up_user' => $row->up_user,
70 'up_property' => $target,
71 'up_value' => $row->up_value,
73 ->onDuplicateKeyUpdate()
74 ->uniqueIndexFields( [
'up_user',
'up_property' ] )
75 ->set( [
'up_value' => $row->up_value ] )
76 ->caller( __METHOD__ )->execute();
78 $processed += $dbw->affectedRows();
82 $this->
output(
"Processed $processed user(s)\n" );
83 $this->
output(
"Finished!\n" );
89require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance script that initializes a user preference based on the value of another preference.
execute()
Do the actual work.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
output( $out, $channel=null)
Throw some output to the user.
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.
getReplicaDB(string|false $virtualDomain=false)
getPrimaryDB(string|false $virtualDomain=false)