--- /dev/null
+<?php
+/**
+ * Makes the required database updates for Special:ProtectedPages
+ * to show all protected pages, even ones before the page restrictions
+ * schema change. All remaining page_restriction column values are moved
+ * to the new table.
+ *
+ * Run via update.php or directly through populateLogSearch.php
+ *
+ * @file
+ * @ingroup Maintenance
+ */
+
+define( 'LOG_SEARCH_BATCH_SIZE', 100 );
+
+function migrate_log_params( $db ) {
+ $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__ );
+ if( !$start ) {
+ die("Nothing to do.\n");
+ }
+ $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__ );
+
+ # Do remaining chunk
+ $end += LOG_SEARCH_BATCH_SIZE - 1;
+ $blockStart = $start;
+ $blockEnd = $start + LOG_SEARCH_BATCH_SIZE - 1;
+ while( $blockEnd <= $end ) {
+ echo "...doing log_id from $blockStart to $blockEnd\n";
+ $cond = "log_id BETWEEN $blockStart AND $blockEnd";
+ $res = $db->select( 'logging', '*', $cond, __FUNCTION__ );
+ $batch = array();
+ while( $row = $db->fetchObject( $res ) ) {
+ // RevisionDelete logs - revisions
+ if( LogEventsList::typeAction( $row, array('delete','suppress'), 'revision' ) ) {
+ $params = LogPage::extractParams( $row->log_params );
+ // Param format: <urlparam> <item CSV> [<ofield> <nfield>]
+ if( count($params) >= 2 ) {
+ $field = RevisionDeleter::getRelationType($params[0]);
+ // B/C, the params may start with a title key
+ if( $field == null ) {
+ array_shift($params);
+ $field = RevisionDeleter::getRelationType($params[0]);
+ }
+ if( $field == null ) {
+ echo "Invalid param type for $row->log_id";
+ continue; // skip this row
+ }
+ $items = explode(',',$params[1]);
+ $log = new LogPage( $row->log_type );
+ $log->addRelations( $field, $items, $row->log_id );
+ }
+ // RevisionDelete logs - log events
+ } else if( LogEventsList::typeAction( $row, array('delete','suppress'), 'event' ) ) {
+ $params = LogPage::extractParams( $row->log_params );
+ // Param format: <item CSV> [<ofield> <nfield>]
+ if( count($params) >= 1 ) {
+ $items = explode(',',$params[0]);
+ $log = new LogPage( $row->log_type );
+ $log->addRelations( 'log_id', $items, $row->log_id );
+ }
+ }
+ }
+ $blockStart += LOG_SEARCH_BATCH_SIZE - 1;
+ $blockEnd += LOG_SEARCH_BATCH_SIZE - 1;
+ wfWaitForSlaves( 5 );
+ }
+ if( $db->insert(
+ 'updatelog',
+ array( 'ul_key' => 'populate log_search' ),
+ __FUNCTION__,
+ 'IGNORE'
+ )
+ ) {
+ wfOut( "log_search population complete.\n" );
+ return true;
+ } else {
+ wfOut( "Could not insert log_search population row.\n" );
+ return false;
+ }
+}
* @ingroup Maintenance
*/
-define( 'BATCH_SIZE', 100 );
-
require_once 'commandLine.inc';
+require_once 'populateLogSearch.inc';
$db =& wfGetDB( DB_MASTER );
if ( !$db->tableExists( 'log_search' ) ) {
}
migrate_log_params( $db );
-
-function migrate_log_params( $db ) {
- $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__ );
- if( !$start ) {
- die("Nothing to do.\n");
- }
- $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__ );
-
- # Do remaining chunk
- $end += BATCH_SIZE - 1;
- $blockStart = $start;
- $blockEnd = $start + BATCH_SIZE - 1;
- while( $blockEnd <= $end ) {
- echo "...doing log_id from $blockStart to $blockEnd\n";
- $cond = "log_id BETWEEN $blockStart AND $blockEnd";
- $res = $db->select( 'logging', '*', $cond, __FUNCTION__ );
- $batch = array();
- while( $row = $db->fetchObject( $res ) ) {
- // RevisionDelete logs - revisions
- if( LogEventsList::typeAction( $row, array('delete','suppress'), 'revision' ) ) {
- $params = LogPage::extractParams( $row->log_params );
- // Param format: <urlparam> <item CSV> [<ofield> <nfield>]
- if( count($params) >= 2 ) {
- $field = RevisionDeleter::getRelationType($params[0]);
- // B/C, the params may start with a title key
- if( $field == null ) {
- array_shift($params);
- $field = RevisionDeleter::getRelationType($params[0]);
- }
- if( $field == null ) {
- echo "Invalid param type for $row->log_id";
- continue; // skip this row
- }
- $items = explode(',',$params[1]);
- $log = new LogPage( $row->log_type );
- $log->addRelations( $field, $items, $row->log_id );
- }
- // RevisionDelete logs - log events
- } else if( LogEventsList::typeAction( $row, array('delete','suppress'), 'event' ) ) {
- $params = LogPage::extractParams( $row->log_params );
- // Param format: <item CSV> [<ofield> <nfield>]
- if( count($params) >= 1 ) {
- $items = explode(',',$params[0]);
- $log = new LogPage( $row->log_type );
- $log->addRelations( 'log_id', $items, $row->log_id );
- }
- }
- }
- $blockStart += BATCH_SIZE - 1;
- $blockEnd += BATCH_SIZE - 1;
- wfWaitForSlaves( 5 );
- }
- echo "...Done!\n";
-}
array( 'add_table', 'valid_tag', 'patch-change_tag.sql' ),
array( 'add_table', 'user_properties', 'patch-user_properties.sql' ),
array( 'add_table', 'log_search', 'patch-log_search.sql' ),
+ array( 'do_log_search_population' ),
),
'sqlite' => array(
}
}
+function do_log_search_population() {
+ if( update_row_exists( 'populate log_search' ) ) {
+ wfOut( "...log_search table already populated.\n" );
+ return;
+ }
+ require_once( 'populateLogSearch.inc' );
+ wfOut(
+"Populating log_search table, printing progress markers. For large\n" .
+"databases, you may want to hit Ctrl-C and do this manually with\n" .
+"maintenance/populateLogSearch.php.\n" );
+ $db =& wfGetDB( DB_MASTER );
+ migrate_log_params( $db );
+ wfOut( "Done populating log_search table.\n" );
+}
+
/***********************************************************************
* Start PG crap
* TODO: merge with above