3 * Makes the required database updates for log display in Special:RevisionDelete
5 * Run via update.php or directly through populateLogSearch.php
11 define( 'LOG_SEARCH_BATCH_SIZE', 100 );
13 function migrate_log_params( $db ) {
14 $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__ );
16 die("Nothing to do.\n");
18 $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__ );
21 $end += LOG_SEARCH_BATCH_SIZE - 1;
23 $blockEnd = $start + LOG_SEARCH_BATCH_SIZE - 1;
24 while( $blockEnd <= $end ) {
25 echo "...doing log_id from $blockStart to $blockEnd\n";
26 $cond = "log_id BETWEEN $blockStart AND $blockEnd";
27 $res = $db->select( 'logging', '*', $cond, __FUNCTION__ );
29 while( $row = $db->fetchObject( $res ) ) {
30 // RevisionDelete logs - revisions
31 if( LogEventsList::typeAction( $row, array('delete','suppress'), 'revision' ) ) {
32 $params = LogPage::extractParams( $row->log_params );
33 // Param format: <urlparam> <item CSV> [<ofield> <nfield>]
34 if( count($params) >= 2 ) {
35 $field = RevisionDeleter::getRelationType($params[0]);
36 // B/C, the params may start with a title key
37 if( $field == null ) {
39 $field = RevisionDeleter::getRelationType($params[0]);
41 if( $field == null ) {
42 echo "Invalid param type for $row->log_id\n";
43 continue; // skip this row
45 $items = explode(',',$params[1]);
46 $log = new LogPage( $row->log_type );
47 $log->addRelations( $field, $items, $row->log_id );
49 // RevisionDelete logs - log events
50 } else if( LogEventsList::typeAction( $row, array('delete','suppress'), 'event' ) ) {
51 $params = LogPage::extractParams( $row->log_params );
52 // Param format: <item CSV> [<ofield> <nfield>]
53 if( count($params) >= 1 ) {
54 $items = explode(',',$params[0]);
55 $log = new LogPage( $row->log_type );
56 $log->addRelations( 'log_id', $items, $row->log_id );
60 $blockStart += LOG_SEARCH_BATCH_SIZE;
61 $blockEnd += LOG_SEARCH_BATCH_SIZE;
66 array( 'ul_key' => 'populate log_search' ),
71 wfOut( "log_search population complete.\n" );
74 wfOut( "Could not insert log_search population row.\n" );