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 echo "Nothing to do.\n";
19 $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__ );
22 $end += LOG_SEARCH_BATCH_SIZE - 1;
24 $blockEnd = $start + LOG_SEARCH_BATCH_SIZE - 1;
25 while( $blockEnd <= $end ) {
26 echo "...doing log_id from $blockStart to $blockEnd\n";
27 $cond = "log_id BETWEEN $blockStart AND $blockEnd";
28 $res = $db->select( 'logging', '*', $cond, __FUNCTION__ );
30 while( $row = $db->fetchObject( $res ) ) {
31 // RevisionDelete logs - revisions
32 if( LogEventsList::typeAction( $row, array('delete','suppress'), 'revision' ) ) {
33 $params = LogPage::extractParams( $row->log_params );
34 // Param format: <urlparam> <item CSV> [<ofield> <nfield>]
35 if( count($params) >= 2 ) {
36 $field = RevisionDeleter::getRelationType($params[0]);
37 // B/C, the params may start with a title key
38 if( $field == null ) {
40 $field = RevisionDeleter::getRelationType($params[0]);
42 if( $field == null ) {
43 echo "Invalid param type for $row->log_id\n";
44 continue; // skip this row
46 $items = explode(',',$params[1]);
47 $log = new LogPage( $row->log_type );
48 $log->addRelations( $field, $items, $row->log_id );
50 // RevisionDelete logs - log events
51 } else if( LogEventsList::typeAction( $row, array('delete','suppress'), 'event' ) ) {
52 $params = LogPage::extractParams( $row->log_params );
53 // Param format: <item CSV> [<ofield> <nfield>]
54 if( count($params) >= 1 ) {
55 $items = explode(',',$params[0]);
56 $log = new LogPage( $row->log_type );
57 $log->addRelations( 'log_id', $items, $row->log_id );
61 $blockStart += LOG_SEARCH_BATCH_SIZE;
62 $blockEnd += LOG_SEARCH_BATCH_SIZE;
67 array( 'ul_key' => 'populate log_search' ),
72 wfOut( "log_search population complete.\n" );
75 wfOut( "Could not insert log_search population row.\n" );