MediaWiki  master
tidyUpT39714.php
Go to the documentation of this file.
1 <?php
2 
3 require_once __DIR__ . '/Maintenance.php';
4 
8 class TidyUpT39714 extends Maintenance {
9  public function execute() {
10  // Search for all log entries which are about changing the visability of other log entries.
11  $result = $this->getDB( DB_REPLICA )->select(
12  'logging',
13  [ 'log_id', 'log_params' ],
14  [
15  'log_type' => [ 'suppress', 'delete' ],
16  'log_action' => 'event',
17  'log_namespace' => NS_SPECIAL,
18  'log_title' => SpecialPage::getTitleFor( 'Log' )->getText()
19  ],
20  __METHOD__
21  );
22 
23  foreach ( $result as $row ) {
24  $ids = explode( ',', explode( "\n", $row->log_params )[0] );
25  $result = $this->getDB( DB_REPLICA )->select( // Work out what log entries were changed here.
26  'logging',
27  'log_type',
28  [ 'log_id' => $ids ],
29  __METHOD__,
30  'DISTINCT'
31  );
32  if ( $result->numRows() === 1 ) {
33  // If there's only one type, the target title can be set to include it.
34  $logTitle = SpecialPage::getTitleFor( 'Log', $result->current()->log_type )->getText();
35  $this->output( 'Set log_title to "' . $logTitle . '" for log entry ' . $row->log_id . ".\n" );
36  $this->getDB( DB_MASTER )->update(
37  'logging',
38  [ 'log_title' => $logTitle ],
39  [ 'log_id' => $row->log_id ],
40  __METHOD__
41  );
43  }
44  }
45  }
46 }
47 
48 $maintClass = TidyUpT39714::class;
49 require_once RUN_MAINTENANCE_IF_MAIN;
Fixes all rows affected by T39714.
Definition: tidyUpT39714.php:8
const RUN_MAINTENANCE_IF_MAIN
Definition: Maintenance.php:39
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
Definition: Maintenance.php:86
const NS_SPECIAL
Definition: Defines.php:49
const DB_MASTER
Definition: defines.php:26
wfWaitForSlaves( $ifWritesSince=null, $wiki=false, $cluster=false, $timeout=null)
Waits for the replica DBs to catch up to the master position.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don&#39;t need a full Title object...
Definition: SpecialPage.php:83
output( $out, $channel=null)
Throw some output to the user.
$maintClass
const DB_REPLICA
Definition: defines.php:25
getDB( $db, $groups=[], $dbDomain=false)
Returns a database to be used by current maintenance script.