00001 <?php
00011 define( 'LOG_SEARCH_BATCH_SIZE', 300 );
00012
00013 function migrate_log_params( $db ) {
00014 $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__ );
00015 if( !$start ) {
00016 echo "Nothing to do.\n";
00017 return true;
00018 }
00019 $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__ );
00020
00021 # Do remaining chunk
00022 $end += LOG_SEARCH_BATCH_SIZE - 1;
00023 $blockStart = $start;
00024 $blockEnd = $start + LOG_SEARCH_BATCH_SIZE - 1;
00025 while( $blockEnd <= $end ) {
00026 echo "...doing log_id from $blockStart to $blockEnd\n";
00027 $cond = array("log_id BETWEEN $blockStart AND $blockEnd");
00028 # Applicable log types
00029 $cond['log_type'] = array('delete','suppress');
00030 $res = $db->select( 'logging', '*', $cond, __FUNCTION__ );
00031 $batch = array();
00032 while( $row = $db->fetchObject( $res ) ) {
00033
00034 if( LogEventsList::typeAction( $row, array('delete','suppress'), 'revision' ) ) {
00035 $params = LogPage::extractParams( $row->log_params );
00036
00037 if( count($params) >= 2 ) {
00038 $field = RevisionDeleter::getRelationType($params[0]);
00039
00040 if( $field == null ) {
00041 array_shift($params);
00042 $field = RevisionDeleter::getRelationType($params[0]);
00043 }
00044 if( $field == null ) {
00045 echo "Invalid param type for $row->log_id\n";
00046 continue;
00047 }
00048 $items = explode(',',$params[1]);
00049 $log = new LogPage( $row->log_type );
00050 $log->addRelations( $field, $items, $row->log_id );
00051 }
00052
00053 } else if( LogEventsList::typeAction( $row, array('delete','suppress'), 'event' ) ) {
00054 $params = LogPage::extractParams( $row->log_params );
00055
00056 if( count($params) >= 1 ) {
00057 $items = explode(',',$params[0]);
00058 $log = new LogPage( $row->log_type );
00059 $log->addRelations( 'log_id', $items, $row->log_id );
00060 }
00061 }
00062 }
00063 $blockStart += LOG_SEARCH_BATCH_SIZE;
00064 $blockEnd += LOG_SEARCH_BATCH_SIZE;
00065 wfWaitForSlaves( 5 );
00066 }
00067 if( $db->insert(
00068 'updatelog',
00069 array( 'ul_key' => 'populate log_search' ),
00070 __FUNCTION__,
00071 'IGNORE'
00072 )
00073 ) {
00074 wfOut( "log_search population complete.\n" );
00075 return true;
00076 } else {
00077 wfOut( "Could not insert log_search population row.\n" );
00078 return false;
00079 }
00080 }