Index: trunk/phase3/maintenance/updaters.inc |
— | — | @@ -158,6 +158,7 @@ |
159 | 159 | array( 'add_table', 'valid_tag', 'patch-change_tag.sql' ), |
160 | 160 | array( 'add_table', 'user_properties', 'patch-user_properties.sql' ), |
161 | 161 | array( 'add_table', 'log_search', 'patch-log_search.sql' ), |
| 162 | + array( 'do_log_search_population' ), |
162 | 163 | ), |
163 | 164 | |
164 | 165 | 'sqlite' => array( |
— | — | @@ -1305,6 +1306,21 @@ |
1306 | 1307 | } |
1307 | 1308 | } |
1308 | 1309 | |
| 1310 | +function do_log_search_population() { |
| 1311 | + if( update_row_exists( 'populate log_search' ) ) { |
| 1312 | + wfOut( "...log_search table already populated.\n" ); |
| 1313 | + return; |
| 1314 | + } |
| 1315 | + require_once( 'populateLogSearch.inc' ); |
| 1316 | + wfOut( |
| 1317 | +"Populating log_search table, printing progress markers. For large\n" . |
| 1318 | +"databases, you may want to hit Ctrl-C and do this manually with\n" . |
| 1319 | +"maintenance/populateLogSearch.php.\n" ); |
| 1320 | + $db =& wfGetDB( DB_MASTER ); |
| 1321 | + migrate_log_params( $db ); |
| 1322 | + wfOut( "Done populating log_search table.\n" ); |
| 1323 | +} |
| 1324 | + |
1309 | 1325 | /*********************************************************************** |
1310 | 1326 | * Start PG crap |
1311 | 1327 | * TODO: merge with above |
Index: trunk/phase3/maintenance/populateLogSearch.inc |
— | — | @@ -0,0 +1,80 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Makes the required database updates for Special:ProtectedPages |
| 5 | + * to show all protected pages, even ones before the page restrictions |
| 6 | + * schema change. All remaining page_restriction column values are moved |
| 7 | + * to the new table. |
| 8 | + * |
| 9 | + * Run via update.php or directly through populateLogSearch.php |
| 10 | + * |
| 11 | + * @file |
| 12 | + * @ingroup Maintenance |
| 13 | + */ |
| 14 | + |
| 15 | +define( 'LOG_SEARCH_BATCH_SIZE', 100 ); |
| 16 | + |
| 17 | +function migrate_log_params( $db ) { |
| 18 | + $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__ ); |
| 19 | + if( !$start ) { |
| 20 | + die("Nothing to do.\n"); |
| 21 | + } |
| 22 | + $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__ ); |
| 23 | + |
| 24 | + # Do remaining chunk |
| 25 | + $end += LOG_SEARCH_BATCH_SIZE - 1; |
| 26 | + $blockStart = $start; |
| 27 | + $blockEnd = $start + LOG_SEARCH_BATCH_SIZE - 1; |
| 28 | + while( $blockEnd <= $end ) { |
| 29 | + echo "...doing log_id from $blockStart to $blockEnd\n"; |
| 30 | + $cond = "log_id BETWEEN $blockStart AND $blockEnd"; |
| 31 | + $res = $db->select( 'logging', '*', $cond, __FUNCTION__ ); |
| 32 | + $batch = array(); |
| 33 | + while( $row = $db->fetchObject( $res ) ) { |
| 34 | + // RevisionDelete logs - revisions |
| 35 | + if( LogEventsList::typeAction( $row, array('delete','suppress'), 'revision' ) ) { |
| 36 | + $params = LogPage::extractParams( $row->log_params ); |
| 37 | + // Param format: <urlparam> <item CSV> [<ofield> <nfield>] |
| 38 | + if( count($params) >= 2 ) { |
| 39 | + $field = RevisionDeleter::getRelationType($params[0]); |
| 40 | + // B/C, the params may start with a title key |
| 41 | + if( $field == null ) { |
| 42 | + array_shift($params); |
| 43 | + $field = RevisionDeleter::getRelationType($params[0]); |
| 44 | + } |
| 45 | + if( $field == null ) { |
| 46 | + echo "Invalid param type for $row->log_id"; |
| 47 | + continue; // skip this row |
| 48 | + } |
| 49 | + $items = explode(',',$params[1]); |
| 50 | + $log = new LogPage( $row->log_type ); |
| 51 | + $log->addRelations( $field, $items, $row->log_id ); |
| 52 | + } |
| 53 | + // RevisionDelete logs - log events |
| 54 | + } else if( LogEventsList::typeAction( $row, array('delete','suppress'), 'event' ) ) { |
| 55 | + $params = LogPage::extractParams( $row->log_params ); |
| 56 | + // Param format: <item CSV> [<ofield> <nfield>] |
| 57 | + if( count($params) >= 1 ) { |
| 58 | + $items = explode(',',$params[0]); |
| 59 | + $log = new LogPage( $row->log_type ); |
| 60 | + $log->addRelations( 'log_id', $items, $row->log_id ); |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | + $blockStart += LOG_SEARCH_BATCH_SIZE - 1; |
| 65 | + $blockEnd += LOG_SEARCH_BATCH_SIZE - 1; |
| 66 | + wfWaitForSlaves( 5 ); |
| 67 | + } |
| 68 | + if( $db->insert( |
| 69 | + 'updatelog', |
| 70 | + array( 'ul_key' => 'populate log_search' ), |
| 71 | + __FUNCTION__, |
| 72 | + 'IGNORE' |
| 73 | + ) |
| 74 | + ) { |
| 75 | + wfOut( "log_search population complete.\n" ); |
| 76 | + return true; |
| 77 | + } else { |
| 78 | + wfOut( "Could not insert log_search population row.\n" ); |
| 79 | + return false; |
| 80 | + } |
| 81 | +} |
Property changes on: trunk/phase3/maintenance/populateLogSearch.inc |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 82 | + native |
Index: trunk/phase3/maintenance/populateLogSearch.php |
— | — | @@ -9,9 +9,8 @@ |
10 | 10 | * @ingroup Maintenance |
11 | 11 | */ |
12 | 12 | |
13 | | -define( 'BATCH_SIZE', 100 ); |
14 | | - |
15 | 13 | require_once 'commandLine.inc'; |
| 14 | +require_once 'populateLogSearch.inc'; |
16 | 15 | |
17 | 16 | $db =& wfGetDB( DB_MASTER ); |
18 | 17 | if ( !$db->tableExists( 'log_search' ) ) { |
— | — | @@ -20,57 +19,3 @@ |
21 | 20 | } |
22 | 21 | |
23 | 22 | migrate_log_params( $db ); |
24 | | - |
25 | | -function migrate_log_params( $db ) { |
26 | | - $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__ ); |
27 | | - if( !$start ) { |
28 | | - die("Nothing to do.\n"); |
29 | | - } |
30 | | - $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__ ); |
31 | | - |
32 | | - # Do remaining chunk |
33 | | - $end += BATCH_SIZE - 1; |
34 | | - $blockStart = $start; |
35 | | - $blockEnd = $start + BATCH_SIZE - 1; |
36 | | - while( $blockEnd <= $end ) { |
37 | | - echo "...doing log_id from $blockStart to $blockEnd\n"; |
38 | | - $cond = "log_id BETWEEN $blockStart AND $blockEnd"; |
39 | | - $res = $db->select( 'logging', '*', $cond, __FUNCTION__ ); |
40 | | - $batch = array(); |
41 | | - while( $row = $db->fetchObject( $res ) ) { |
42 | | - // RevisionDelete logs - revisions |
43 | | - if( LogEventsList::typeAction( $row, array('delete','suppress'), 'revision' ) ) { |
44 | | - $params = LogPage::extractParams( $row->log_params ); |
45 | | - // Param format: <urlparam> <item CSV> [<ofield> <nfield>] |
46 | | - if( count($params) >= 2 ) { |
47 | | - $field = RevisionDeleter::getRelationType($params[0]); |
48 | | - // B/C, the params may start with a title key |
49 | | - if( $field == null ) { |
50 | | - array_shift($params); |
51 | | - $field = RevisionDeleter::getRelationType($params[0]); |
52 | | - } |
53 | | - if( $field == null ) { |
54 | | - echo "Invalid param type for $row->log_id"; |
55 | | - continue; // skip this row |
56 | | - } |
57 | | - $items = explode(',',$params[1]); |
58 | | - $log = new LogPage( $row->log_type ); |
59 | | - $log->addRelations( $field, $items, $row->log_id ); |
60 | | - } |
61 | | - // RevisionDelete logs - log events |
62 | | - } else if( LogEventsList::typeAction( $row, array('delete','suppress'), 'event' ) ) { |
63 | | - $params = LogPage::extractParams( $row->log_params ); |
64 | | - // Param format: <item CSV> [<ofield> <nfield>] |
65 | | - if( count($params) >= 1 ) { |
66 | | - $items = explode(',',$params[0]); |
67 | | - $log = new LogPage( $row->log_type ); |
68 | | - $log->addRelations( 'log_id', $items, $row->log_id ); |
69 | | - } |
70 | | - } |
71 | | - } |
72 | | - $blockStart += BATCH_SIZE - 1; |
73 | | - $blockEnd += BATCH_SIZE - 1; |
74 | | - wfWaitForSlaves( 5 ); |
75 | | - } |
76 | | - echo "...Done!\n"; |
77 | | -} |