X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FpopulateLogSearch.php;h=4c1a72e81ce0167c73150bd006d6a7e4b3f40802;hb=3a45b422f5e84677810e630a0a5c54f07f29a804;hp=99d8155766d300e0c9247f49b8be6a69b9680503;hpb=f6cbdfb5e2c3ffc05858612e219a24e22bdbc72e;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateLogSearch.php b/maintenance/populateLogSearch.php index 99d8155766..4c1a72e81c 100644 --- a/maintenance/populateLogSearch.php +++ b/maintenance/populateLogSearch.php @@ -22,7 +22,7 @@ * @ingroup Maintenance */ -require_once( __DIR__ . '/Maintenance.php' ); +require_once __DIR__ . '/Maintenance.php'; /** * Maintenance script that makes the required database updates for populating the @@ -31,7 +31,12 @@ require_once( __DIR__ . '/Maintenance.php' ); * @ingroup Maintenance */ class PopulateLogSearch extends LoggedUpdateMaintenance { - static $tableMap = array( 'rev' => 'revision', 'fa' => 'filearchive', 'oi' => 'oldimage', 'ar' => 'archive' ); + private static $tableMap = array( + 'rev' => 'revision', + 'fa' => 'filearchive', + 'oi' => 'oldimage', + 'ar' => 'archive' + ); public function __construct() { parent::__construct(); @@ -51,11 +56,13 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { $db = $this->getDB( DB_MASTER ); if ( !$db->tableExists( 'log_search' ) ) { $this->error( "log_search does not exist" ); + return false; } $start = $db->selectField( 'logging', 'MIN(log_id)', false, __FUNCTION__ ); if ( !$start ) { $this->output( "Nothing to do.\n" ); + return true; } $end = $db->selectField( 'logging', 'MAX(log_id)', false, __FUNCTION__ ); @@ -75,7 +82,9 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { if ( LogEventsList::typeAction( $row, $delTypes, 'revision' ) ) { $params = LogPage::extractParams( $row->log_params ); // Param format: [ ] - if ( count( $params ) < 2 ) continue; // bad row? + if ( count( $params ) < 2 ) { + continue; // bad row? + } $field = RevisionDeleter::getRelationType( $params[0] ); // B/C, the params may start with a title key ( <urlparam> <CSV>) if ( $field == null ) { @@ -97,8 +106,9 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { $log->addRelations( $field, $items, $row->log_id ); // Determine what table to query... $prefix = substr( $field, 0, strpos( $field, '_' ) ); // db prefix - if ( !isset( self::$tableMap[$prefix] ) ) + if ( !isset( self::$tableMap[$prefix] ) ) { continue; // bad row? + } $table = self::$tableMap[$prefix]; $userField = $prefix . '_user'; $userTextField = $prefix . '_user_text'; @@ -109,19 +119,22 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { array( $field => $items ) ); foreach ( $sres as $srow ) { - if ( $srow->$userField > 0 ) + if ( $srow->$userField > 0 ) { $userIds[] = intval( $srow->$userField ); - elseif ( $srow->$userTextField != '' ) + } elseif ( $srow->$userTextField != '' ) { $userIPs[] = $srow->$userTextField; + } } // Add item author relations... $log->addRelations( 'target_author_id', $userIds, $row->log_id ); $log->addRelations( 'target_author_ip', $userIPs, $row->log_id ); - // RevisionDelete logs - log events } elseif ( LogEventsList::typeAction( $row, $delTypes, 'event' ) ) { + // RevisionDelete logs - log events $params = LogPage::extractParams( $row->log_params ); // Param format: <item CSV> [<ofield> <nfield>] - if ( count( $params ) < 1 ) continue; // bad row + if ( count( $params ) < 1 ) { + continue; // bad row + } $items = explode( ',', $params[0] ); $log = new LogPage( $row->log_type ); // Add item relations... @@ -133,10 +146,11 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { array( 'log_id' => $items ) ); foreach ( $sres as $srow ) { - if ( $srow->log_user > 0 ) + if ( $srow->log_user > 0 ) { $userIds[] = intval( $srow->log_user ); - elseif ( IP::isIPAddress( $srow->log_user_text ) ) + } elseif ( IP::isIPAddress( $srow->log_user_text ) ) { $userIPs[] = $srow->log_user_text; + } } $log->addRelations( 'target_author_id', $userIds, $row->log_id ); $log->addRelations( 'target_author_ip', $userIPs, $row->log_id ); @@ -147,9 +161,10 @@ class PopulateLogSearch extends LoggedUpdateMaintenance { wfWaitForSlaves(); } $this->output( "Done populating log_search table.\n" ); + return true; } } $maintClass = "PopulateLogSearch"; -require_once( RUN_MAINTENANCE_IF_MAIN ); +require_once RUN_MAINTENANCE_IF_MAIN;