MediaWiki REL1_37
tidyUpT39714.php
Go to the documentation of this file.
1<?php
2
3require_once __DIR__ . '/Maintenance.php';
4
6
11 public function execute() {
12 // Search for all log entries which are about changing the visability of other log entries.
13 $result = $this->getDB( DB_REPLICA )->select(
14 'logging',
15 [ 'log_id', 'log_params' ],
16 [
17 'log_type' => [ 'suppress', 'delete' ],
18 'log_action' => 'event',
19 'log_namespace' => NS_SPECIAL,
20 'log_title' => SpecialPage::getTitleFor( 'Log' )->getText()
21 ],
22 __METHOD__
23 );
24
25 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
26 foreach ( $result as $row ) {
27 $ids = explode( ',', explode( "\n", $row->log_params )[0] );
28 // Work out what log entries were changed here.
29 $result = $this->getDB( DB_REPLICA )->select(
30 'logging',
31 'log_type',
32 [ 'log_id' => $ids ],
33 __METHOD__,
34 'DISTINCT'
35 );
36 if ( $result->numRows() === 1 ) {
37 // If there's only one type, the target title can be set to include it.
38 $logTitle = SpecialPage::getTitleFor( 'Log', $result->current()->log_type )->getText();
39 $this->output( 'Set log_title to "' . $logTitle . '" for log entry ' . $row->log_id . ".\n" );
40 $this->getDB( DB_PRIMARY )->update(
41 'logging',
42 [ 'log_title' => $logTitle ],
43 [ 'log_id' => $row->log_id ],
44 __METHOD__
45 );
46 $lbFactory->waitForReplication();
47 }
48 }
49 }
50}
51
52$maintClass = TidyUpT39714::class;
53require_once RUN_MAINTENANCE_IF_MAIN;
getDB()
const NS_SPECIAL
Definition Defines.php:53
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
output( $out, $channel=null)
Throw some output to the user.
MediaWikiServices is the service locator for the application scope of MediaWiki.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Fixes all rows affected by T39714.
execute()
Do the actual work.
const DB_REPLICA
Definition defines.php:25
const DB_PRIMARY
Definition defines.php:27
$maintClass