From: Alex Monk Date: Sun, 6 Jan 2013 13:06:44 +0000 (+0000) Subject: Tidy up log deletion rows which didn't get subpages X-Git-Tag: 1.31.0-rc.0~18712 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=50af25f5b3fca169ada0568133939a95bd8f8d7c;p=lhc%2Fweb%2Fwiklou.git Tidy up log deletion rows which didn't get subpages Bug: 37714 Change-Id: I904988c864d777d039b2aae956aef7b19092cf83 --- diff --git a/maintenance/tidyUpBug37714.php b/maintenance/tidyUpBug37714.php new file mode 100644 index 0000000000..1ad9c7ee25 --- /dev/null +++ b/maintenance/tidyUpBug37714.php @@ -0,0 +1,49 @@ +select( + 'logging', + array( 'log_id', 'log_params' ), + array( + 'log_type' => array( 'suppress', 'delete' ), + 'log_action' => 'event', + 'log_namespace' => NS_SPECIAL, + 'log_title' => SpecialPage::getTitleFor( 'Log' )->getText() + ), + __METHOD__ + ); + + foreach ( $result as $row ) { + $paramLines = explode( "\n", $row->log_params ); + $ids = explode( ',', $paramLines[0] ); // Array dereferencing is PHP >= 5.4 :( + $result = wfGetDB( DB_SLAVE )->select( // Work out what log entries were changed here. + 'logging', + 'log_type', + array( 'log_id' => $ids ), + __METHOD__, + 'DISTINCT' + ); + if ( $result->numRows() === 1 ) { + // If there's only one type, the target title can be set to include it. + $logTitle = SpecialPage::getTitleFor( 'Log', $result->current()->log_type )->getText(); + $this->output( 'Set log_title to "' . $logTitle . '" for log entry ' . $row->log_id . ".\n" ); + wfGetDB( DB_MASTER )->update( + 'logging', + array( 'log_title' => $logTitle ), + array( 'log_id' => $row->log_id ), + __METHOD__ + ); + wfWaitForSlaves(); + } + } + } +} + +$maintClass = 'TidyUpBug37714'; +require_once RUN_MAINTENANCE_IF_MAIN;