3 require_once __DIR__
. '/Maintenance.php';
5 use MediaWiki\MediaWikiServices
;
8 * Fixes all rows affected by T39714
10 class TidyUpT39714
extends Maintenance
{
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(
15 [ 'log_id', 'log_params' ],
17 'log_type' => [ 'suppress', 'delete' ],
18 'log_action' => 'event',
19 'log_namespace' => NS_SPECIAL
,
20 'log_title' => SpecialPage
::getTitleFor( 'Log' )->getText()
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(
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_MASTER
)->update(
42 [ 'log_title' => $logTitle ],
43 [ 'log_id' => $row->log_id
],
46 $lbFactory->waitForReplication();
52 $maintClass = TidyUpT39714
::class;
53 require_once RUN_MAINTENANCE_IF_MAIN
;