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 define( 'BATCH_SIZE', 100 );
14 require_once 'commandLine.inc';
16 $db =& wfGetDB( DB_MASTER
);
17 if ( !$db->tableExists( 'log_search' ) ) {
18 echo "log_search does not exist\n";
22 migrate_log_params( $db );
24 function migrate_log_params( $db ) {
25 $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__
);
27 die("Nothing to do.\n");
29 $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__
);
32 $end +
= BATCH_SIZE
- 1;
34 $blockEnd = $start + BATCH_SIZE
- 1;
35 while( $blockEnd <= $end ) {
36 echo "...doing log_id from $blockStart to $blockEnd\n";
37 $cond = "log_id BETWEEN $blockStart AND $blockEnd";
38 $res = $db->select( 'logging', '*', $cond, __FUNCTION__
);
40 while( $row = $db->fetchObject( $res ) ) {
41 // RevisionDelete logs - revisions
42 if( LogEventsList
::typeAction( $row, array('delete','suppress'), 'revision' ) ) {
43 $params = LogPage
::extractParams( $row->log_params
);
44 // Param format: <urlparam> <item CSV> [<ofield> <nfield>]
45 if( count($params) >= 2 ) {
46 $field = RevisionDeleter
::getRelationType($params[0]);
47 // B/C, the params may start with a title key
48 if( $field == null ) {
50 $field = RevisionDeleter
::getRelationType($params[0]);
52 if( $field == null ) {
53 echo "Invalid param type for $row->log_id";
54 continue; // skip this row
56 $items = explode(',',$params[1]);
57 $log = new LogPage( $row->log_type
);
58 $log->addRelations( $field, $items, $row->log_id
);
60 // RevisionDelete logs - log events
61 } else if( LogEventsList
::typeAction( $row, array('delete','suppress'), 'event' ) ) {
62 $params = LogPage
::extractParams( $row->log_params
);
63 // Param format: <item CSV> [<ofield> <nfield>]
64 if( count($params) >= 1 ) {
65 $items = explode(',',$params[0]);
66 $log = new LogPage( $row->log_type
);
67 $log->addRelations( 'log_id', $items, $row->log_id
);
71 $blockStart +
= BATCH_SIZE
- 1;
72 $blockEnd +
= BATCH_SIZE
- 1;