MediaWiki  REL1_22
tidyUpBug37714.php
Go to the documentation of this file.
00001 <?php
00002 require_once __DIR__ . '/Maintenance.php';
00003 
00007 class TidyUpBug37714 extends Maintenance {
00008     public function execute() {
00009         // Search for all log entries which are about changing the visability of other log entries.
00010         $result = wfGetDB( DB_SLAVE )->select(
00011             'logging',
00012             array( 'log_id', 'log_params' ),
00013             array(
00014                 'log_type' => array( 'suppress', 'delete' ),
00015                 'log_action' => 'event',
00016                 'log_namespace' => NS_SPECIAL,
00017                 'log_title' => SpecialPage::getTitleFor( 'Log' )->getText()
00018             ),
00019             __METHOD__
00020         );
00021 
00022         foreach ( $result as $row ) {
00023             $paramLines = explode( "\n", $row->log_params );
00024             $ids = explode( ',', $paramLines[0] ); // Array dereferencing is PHP >= 5.4 :(
00025             $result = wfGetDB( DB_SLAVE )->select( // Work out what log entries were changed here.
00026                 'logging',
00027                 'log_type',
00028                 array( 'log_id' => $ids ),
00029                 __METHOD__,
00030                 'DISTINCT'
00031             );
00032             if ( $result->numRows() === 1 ) {
00033                 // If there's only one type, the target title can be set to include it.
00034                 $logTitle = SpecialPage::getTitleFor( 'Log', $result->current()->log_type )->getText();
00035                 $this->output( 'Set log_title to "' . $logTitle . '" for log entry ' . $row->log_id . ".\n" );
00036                 wfGetDB( DB_MASTER )->update(
00037                     'logging',
00038                     array( 'log_title' => $logTitle ),
00039                     array( 'log_id' => $row->log_id ),
00040                     __METHOD__
00041                 );
00042                 wfWaitForSlaves();
00043             }
00044         }
00045     }
00046 }
00047 
00048 $maintClass = 'TidyUpBug37714';
00049 require_once RUN_MAINTENANCE_IF_MAIN;