01b04b5f01288ff2f74d56cb54dcdcb7376ecc52
3 * Makes the required database updates for Special:ProtectedPages
4 * to show all protected pages, even ones before the page restrictions
5 * schema change. All remaining page_restriction column values are moved
12 require_once( "Maintenance.php" );
14 class PopulateLogSearch
extends Maintenance
{
16 const LOG_SEARCH_BATCH_SIZE
= 100;
18 public function __construct() {
19 parent
::__construct();
20 $this->mDescription
= "Migrate log params to new table and index for searching";
23 public function execute() {
24 $db = wfGetDB( DB_MASTER
);
25 if ( !$db->tableExists( 'log_search' ) ) {
26 $this->error( "log_search does not exist\n", true );
28 $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__
);
30 $this->output( "Nothing to do.\n" );
33 $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__
);
36 $end +
= self
::LOG_SEARCH_BATCH_SIZE
- 1;
38 $blockEnd = $start + self
::LOG_SEARCH_BATCH_SIZE
- 1;
39 while( $blockEnd <= $end ) {
40 $this->output( "...doing log_id from $blockStart to $blockEnd\n" );
41 $cond = "log_id BETWEEN $blockStart AND $blockEnd";
42 $res = $db->select( 'logging', '*', $cond, __FUNCTION__
);
44 while( $row = $db->fetchObject( $res ) ) {
45 // RevisionDelete logs - revisions
46 if( LogEventsList
::typeAction( $row, array('delete','suppress'), 'revision' ) ) {
47 $params = LogPage
::extractParams( $row->log_params
);
48 // Param format: <urlparam> <item CSV> [<ofield> <nfield>]
49 if( count($params) >= 2 ) {
50 $field = RevisionDeleter
::getRelationType($params[0]);
51 // B/C, the params may start with a title key
52 if( $field == null ) {
54 $field = RevisionDeleter
::getRelationType($params[0]);
56 if( $field == null ) {
57 $this->output( "Invalid param type for $row->log_id\n" );
58 continue; // skip this row
60 $items = explode(',',$params[1]);
61 $log = new LogPage( $row->log_type
);
62 $log->addRelations( $field, $items, $row->log_id
);
64 // RevisionDelete logs - log events
65 } else if( LogEventsList
::typeAction( $row, array('delete','suppress'), 'event' ) ) {
66 $params = LogPage
::extractParams( $row->log_params
);
67 // Param format: <item CSV> [<ofield> <nfield>]
68 if( count($params) >= 1 ) {
69 $items = explode(',',$params[0]);
70 $log = new LogPage( $row->log_type
);
71 $log->addRelations( 'log_id', $items, $row->log_id
);
75 $blockStart +
= self
::LOG_SEARCH_BATCH_SIZE
;
76 $blockEnd +
= self
::LOG_SEARCH_BATCH_SIZE
;
81 array( 'ul_key' => 'populate log_search' ),
86 $this->output( "log_search population complete.\n" );
89 $this->output( "Could not insert log_search population row.\n" );
95 $maintClass = "PopulateLogSearch";
96 require_once( DO_MAINTENANCE
);