MediaWiki  1.23.15
fixUserRegistration.php
Go to the documentation of this file.
1 <?php
25 require_once __DIR__ . '/Maintenance.php';
26 
33  public function __construct() {
34  parent::__construct();
35  $this->mDescription = "Fix the user_registration field";
36  }
37 
38  public function execute() {
39  $dbr = wfGetDB( DB_SLAVE );
40  $dbw = wfGetDB( DB_MASTER );
41 
42  // Get user IDs which need fixing
43  $res = $dbr->select( 'user', 'user_id', 'user_registration IS NULL', __METHOD__ );
44  foreach ( $res as $row ) {
45  $id = $row->user_id;
46  // Get first edit time
47  $timestamp = $dbr->selectField( 'revision', 'MIN(rev_timestamp)', array( 'rev_user' => $id ), __METHOD__ );
48  // Update
49  if ( !empty( $timestamp ) ) {
50  $dbw->update( 'user', array( 'user_registration' => $timestamp ), array( 'user_id' => $id ), __METHOD__ );
51  $this->output( "$id $timestamp\n" );
52  } else {
53  $this->output( "$id NULL\n" );
54  }
55  }
56  $this->output( "\n" );
57  }
58 }
59 
60 $maintClass = "FixUserRegistration";
61 require_once RUN_MAINTENANCE_IF_MAIN;
DB_MASTER
const DB_MASTER
Definition: Defines.php:56
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
$maintClass
$maintClass
Definition: fixUserRegistration.php:60
wfGetDB
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3714
$timestamp
if( $limit) $timestamp
Definition: importImages.php:104
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
Maintenance
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: maintenance.txt:39
$dbr
$dbr
Definition: testCompression.php:48
FixUserRegistration\__construct
__construct()
Default constructor.
Definition: fixUserRegistration.php:33
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
FixUserRegistration
Maintenance script that fixes the user_registration field.
Definition: fixUserRegistration.php:32
FixUserRegistration\execute
execute()
Do the actual work.
Definition: fixUserRegistration.php:38
DB_SLAVE
const DB_SLAVE
Definition: Defines.php:55
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
$res
$res
Definition: database.txt:21