MediaWiki  1.23.14
populateLogUsertext.php
Go to the documentation of this file.
1 <?php
27 require_once __DIR__ . '/Maintenance.php';
28 
36  public function __construct() {
37  parent::__construct();
38  $this->mDescription = "Populates the log_user_text field";
39  $this->setBatchSize( 100 );
40  }
41 
42  protected function getUpdateKey() {
43  return 'populate log_usertext';
44  }
45 
46  protected function updateSkippedMessage() {
47  return 'log_user_text column of logging table already populated.';
48  }
49 
50  protected function doDBUpdates() {
51  $db = $this->getDB( DB_MASTER );
52  $start = $db->selectField( 'logging', 'MIN(log_id)', false, __METHOD__ );
53  if ( !$start ) {
54  $this->output( "Nothing to do.\n" );
55  return true;
56  }
57  $end = $db->selectField( 'logging', 'MAX(log_id)', false, __METHOD__ );
58 
59  # Do remaining chunk
60  $end += $this->mBatchSize - 1;
61  $blockStart = $start;
62  $blockEnd = $start + $this->mBatchSize - 1;
63  while ( $blockEnd <= $end ) {
64  $this->output( "...doing log_id from $blockStart to $blockEnd\n" );
65  $cond = "log_id BETWEEN $blockStart AND $blockEnd AND log_user = user_id";
66  $res = $db->select( array( 'logging', 'user' ),
67  array( 'log_id', 'user_name' ), $cond, __METHOD__ );
68 
69  $db->begin( __METHOD__ );
70  foreach ( $res as $row ) {
71  $db->update( 'logging', array( 'log_user_text' => $row->user_name ),
72  array( 'log_id' => $row->log_id ), __METHOD__ );
73  }
74  $db->commit( __METHOD__ );
75  $blockStart += $this->mBatchSize;
76  $blockEnd += $this->mBatchSize;
78  }
79  $this->output( "Done populating log_user_text field.\n" );
80  return true;
81  }
82 }
83 
84 $maintClass = "PopulateLogUsertext";
85 require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance\$mBatchSize
int $mBatchSize
Batch size.
Definition: Maintenance.php:97
PopulateLogUsertext\updateSkippedMessage
updateSkippedMessage()
Message to show that the update was done already and was just skipped.
Definition: populateLogUsertext.php:46
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
PopulateLogUsertext\doDBUpdates
doDBUpdates()
Do the actual work.
Definition: populateLogUsertext.php:50
RUN_MAINTENANCE_IF_MAIN
require_once RUN_MAINTENANCE_IF_MAIN
Definition: maintenance.txt:50
PopulateLogUsertext\__construct
__construct()
Default constructor.
Definition: populateLogUsertext.php:36
Maintenance\getDB
& getDB( $db, $groups=array(), $wiki=false)
Returns a database to be used by current maintenance script.
Definition: Maintenance.php:1007
LoggedUpdateMaintenance
Class for scripts that perform database maintenance and want to log the update in updatelog so we can...
Definition: Maintenance.php:1209
PopulateLogUsertext\getUpdateKey
getUpdateKey()
Get the update key name to go in the update log table.
Definition: populateLogUsertext.php:42
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
wfWaitForSlaves
wfWaitForSlaves( $maxLag=false, $wiki=false, $cluster=false)
Modern version of wfWaitForSlaves().
Definition: GlobalFunctions.php:3859
$maintClass
$maintClass
Definition: populateLogUsertext.php:84
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
PopulateLogUsertext
Maintenance script that makes the required database updates for Special:ProtectedPages to show all pr...
Definition: populateLogUsertext.php:35
Maintenance\output
output( $out, $channel=null)
Throw some output to the user.
Definition: Maintenance.php:314
$res
$res
Definition: database.txt:21
Maintenance\setBatchSize
setBatchSize( $s=0)
Set the batch size.
Definition: Maintenance.php:254