From: Aaron Schulz Date: Thu, 14 May 2009 19:49:33 +0000 (+0000) Subject: Tweaks to r50567: X-Git-Tag: 1.31.0-rc.0~41806 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=8432c504c34efaff080c10f722ba08aa17c5ff66;p=lhc%2Fweb%2Fwiklou.git Tweaks to r50567: * Improved exception handling * Removed redundant ls_log_id cond * Added log_type to getLogQueryCond() * Don't show duplicate rows in log results * populateLogSearch now handles an older log_param format --- diff --git a/includes/LogEventsList.php b/includes/LogEventsList.php index 1617fa47aa..7fee678d69 100644 --- a/includes/LogEventsList.php +++ b/includes/LogEventsList.php @@ -653,11 +653,13 @@ class LogPager extends ReverseChronologicalPager { public function getQueryInfo() { $tables = array( 'logging', 'user' ); $this->mConds[] = 'user_id = log_user'; + $groupBy = false; $index = array(); # Add log_search table if there are conditions on it if( array_key_exists('ls_field',$this->mConds) ) { $tables[] = 'log_search'; $index = array( 'log_search' => 'PRIMARY', 'logging' => 'PRIMARY' ); + $groupBy = 'ls_log_id'; # Don't use the wrong logging index } else if( $this->title || $this->pattern || $this->user ) { $index = array( 'logging' => array('page_time','user_time') ); @@ -666,16 +668,22 @@ class LogPager extends ReverseChronologicalPager { } else { $index = array( 'logging' => 'times' ); } + $options = array( 'USE INDEX' => $index ); + # Don't show duplicate rows when using log_search + if( $groupBy ) $options['GROUP BY'] = $groupBy; $info = array( - 'tables' => $tables, - 'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace', 'log_title', 'log_params', - 'log_comment', 'log_id', 'log_deleted', 'log_timestamp', 'user_name', 'user_editcount' ), - 'conds' => $this->mConds, - 'options' => array( 'USE INDEX' => $index ), - 'join_conds' => array( 'user' => array( 'INNER JOIN', 'user_id=log_user' ), - 'log_search' => array( 'INNER JOIN', 'ls_log_id=log_id' ) ), + 'tables' => $tables, + 'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace', + 'log_title', 'log_params', 'log_comment', 'log_id', 'log_deleted', + 'log_timestamp', 'user_name', 'user_editcount' ), + 'conds' => $this->mConds, + 'options' => $options, + 'join_conds' => array( + 'user' => array( 'INNER JOIN', 'user_id=log_user' ), + 'log_search' => array( 'INNER JOIN', 'ls_log_id=log_id' ) + ) ); - + # Add ChangeTags filter query ChangeTags::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'], $info['join_conds'], $info['options'], $this->mTagFilter ); diff --git a/includes/LogPage.php b/includes/LogPage.php index bb4cecb1b2..4d0bea1234 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -379,7 +379,7 @@ class LogPage { * @static */ public function addRelations( $field, $values, $logid ) { - if( empty($values) ) + if( !strlen($field) || empty($values) ) return false; // nothing $data = array(); foreach( $values as $value ) { diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index 35f32d3bb8..68f4f875da 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -120,6 +120,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { } private function getLogQueryCond() { + $conds = array(); $logAction = 'revision'; switch( $this->deleteKey ) { case 'oldid': @@ -142,10 +143,10 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { return array(); } // Revision delete logs for these item - $conds = array( 'log_action' => $logAction ); + $conds['log_type'] = array('delete','suppress'); + $conds['log_action'] = $logAction; $conds['ls_field'] = RevisionDeleter::getRelationType( $this->deleteKey ); $conds['ls_value'] = $ids; - $conds[] = 'log_id = ls_log_id'; return $conds; } @@ -1527,9 +1528,12 @@ class RevisionDeleter { * @param string $param, URL param * @param Array $items */ - function updateLog( $title, $count, $nbitfield, $obitfield, $comment, $target, + protected function updateLog( $title, $count, $nbitfield, $obitfield, $comment, $target, $param, $items = array() ) { + // Get the URL param's corresponding DB field + if( !($field = self::getRelationType($param)) ) + throw new MWException( "Bad log URL param type!" ); // Put things hidden from sysops in the oversight log $logType = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ? 'suppress' : 'delete'; @@ -1547,7 +1551,7 @@ class RevisionDeleter { $log = new LogPage( $logType ); $logid = $log->addEntry( $logAction, $title, $comment, $params ); // Allow for easy searching of deletion log items for revision/log items - $log->addRelations( self::getRelationType($param), $items, $logid ); + $log->addRelations( $field, $items, $logid ); } // Get DB field name for URL param... @@ -1566,6 +1570,6 @@ class RevisionDeleter { case 'logid': return 'log_id'; } - throw new MWException( "Bad log URL param type!" ); + return null; // bad URL type } } \ No newline at end of file diff --git a/maintenance/populateLogSearch.php b/maintenance/populateLogSearch.php index 88127bfe7d..6205f7e2fc 100644 --- a/maintenance/populateLogSearch.php +++ b/maintenance/populateLogSearch.php @@ -44,6 +44,15 @@ function migrate_log_params( $db ) { // Param format: [ ] 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 );