Index: trunk/phase3/maintenance/populateLogSearch.php |
— | — | @@ -44,6 +44,15 @@ |
45 | 45 | // Param format: <urlparam> <item CSV> [<ofield> <nfield>] |
46 | 46 | if( count($params) >= 2 ) { |
47 | 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 | + } |
48 | 57 | $items = explode(',',$params[1]); |
49 | 58 | $log = new LogPage( $row->log_type ); |
50 | 59 | $log->addRelations( $field, $items, $row->log_id ); |
Index: trunk/phase3/includes/LogEventsList.php |
— | — | @@ -653,11 +653,13 @@ |
654 | 654 | public function getQueryInfo() { |
655 | 655 | $tables = array( 'logging', 'user' ); |
656 | 656 | $this->mConds[] = 'user_id = log_user'; |
| 657 | + $groupBy = false; |
657 | 658 | $index = array(); |
658 | 659 | # Add log_search table if there are conditions on it |
659 | 660 | if( array_key_exists('ls_field',$this->mConds) ) { |
660 | 661 | $tables[] = 'log_search'; |
661 | 662 | $index = array( 'log_search' => 'PRIMARY', 'logging' => 'PRIMARY' ); |
| 663 | + $groupBy = 'ls_log_id'; |
662 | 664 | # Don't use the wrong logging index |
663 | 665 | } else if( $this->title || $this->pattern || $this->user ) { |
664 | 666 | $index = array( 'logging' => array('page_time','user_time') ); |
— | — | @@ -666,16 +668,22 @@ |
667 | 669 | } else { |
668 | 670 | $index = array( 'logging' => 'times' ); |
669 | 671 | } |
| 672 | + $options = array( 'USE INDEX' => $index ); |
| 673 | + # Don't show duplicate rows when using log_search |
| 674 | + if( $groupBy ) $options['GROUP BY'] = $groupBy; |
670 | 675 | $info = array( |
671 | | - 'tables' => $tables, |
672 | | - 'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace', 'log_title', 'log_params', |
673 | | - 'log_comment', 'log_id', 'log_deleted', 'log_timestamp', 'user_name', 'user_editcount' ), |
674 | | - 'conds' => $this->mConds, |
675 | | - 'options' => array( 'USE INDEX' => $index ), |
676 | | - 'join_conds' => array( 'user' => array( 'INNER JOIN', 'user_id=log_user' ), |
677 | | - 'log_search' => array( 'INNER JOIN', 'ls_log_id=log_id' ) ), |
| 676 | + 'tables' => $tables, |
| 677 | + 'fields' => array( 'log_type', 'log_action', 'log_user', 'log_namespace', |
| 678 | + 'log_title', 'log_params', 'log_comment', 'log_id', 'log_deleted', |
| 679 | + 'log_timestamp', 'user_name', 'user_editcount' ), |
| 680 | + 'conds' => $this->mConds, |
| 681 | + 'options' => $options, |
| 682 | + 'join_conds' => array( |
| 683 | + 'user' => array( 'INNER JOIN', 'user_id=log_user' ), |
| 684 | + 'log_search' => array( 'INNER JOIN', 'ls_log_id=log_id' ) |
| 685 | + ) |
678 | 686 | ); |
679 | | - |
| 687 | + # Add ChangeTags filter query |
680 | 688 | ChangeTags::modifyDisplayQuery( $info['tables'], $info['fields'], $info['conds'], |
681 | 689 | $info['join_conds'], $info['options'], $this->mTagFilter ); |
682 | 690 | |
Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php |
— | — | @@ -120,6 +120,7 @@ |
121 | 121 | } |
122 | 122 | |
123 | 123 | private function getLogQueryCond() { |
| 124 | + $conds = array(); |
124 | 125 | $logAction = 'revision'; |
125 | 126 | switch( $this->deleteKey ) { |
126 | 127 | case 'oldid': |
— | — | @@ -142,10 +143,10 @@ |
143 | 144 | return array(); |
144 | 145 | } |
145 | 146 | // Revision delete logs for these item |
146 | | - $conds = array( 'log_action' => $logAction ); |
| 147 | + $conds['log_type'] = array('delete','suppress'); |
| 148 | + $conds['log_action'] = $logAction; |
147 | 149 | $conds['ls_field'] = RevisionDeleter::getRelationType( $this->deleteKey ); |
148 | 150 | $conds['ls_value'] = $ids; |
149 | | - $conds[] = 'log_id = ls_log_id'; |
150 | 151 | return $conds; |
151 | 152 | } |
152 | 153 | |
— | — | @@ -1527,9 +1528,12 @@ |
1528 | 1529 | * @param string $param, URL param |
1529 | 1530 | * @param Array $items |
1530 | 1531 | */ |
1531 | | - function updateLog( $title, $count, $nbitfield, $obitfield, $comment, $target, |
| 1532 | + protected function updateLog( $title, $count, $nbitfield, $obitfield, $comment, $target, |
1532 | 1533 | $param, $items = array() ) |
1533 | 1534 | { |
| 1535 | + // Get the URL param's corresponding DB field |
| 1536 | + if( !($field = self::getRelationType($param)) ) |
| 1537 | + throw new MWException( "Bad log URL param type!" ); |
1534 | 1538 | // Put things hidden from sysops in the oversight log |
1535 | 1539 | $logType = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ? |
1536 | 1540 | 'suppress' : 'delete'; |
— | — | @@ -1547,7 +1551,7 @@ |
1548 | 1552 | $log = new LogPage( $logType ); |
1549 | 1553 | $logid = $log->addEntry( $logAction, $title, $comment, $params ); |
1550 | 1554 | // Allow for easy searching of deletion log items for revision/log items |
1551 | | - $log->addRelations( self::getRelationType($param), $items, $logid ); |
| 1555 | + $log->addRelations( $field, $items, $logid ); |
1552 | 1556 | } |
1553 | 1557 | |
1554 | 1558 | // Get DB field name for URL param... |
— | — | @@ -1566,6 +1570,6 @@ |
1567 | 1571 | case 'logid': |
1568 | 1572 | return 'log_id'; |
1569 | 1573 | } |
1570 | | - throw new MWException( "Bad log URL param type!" ); |
| 1574 | + return null; // bad URL type |
1571 | 1575 | } |
1572 | 1576 | } |
\ No newline at end of file |
Index: trunk/phase3/includes/LogPage.php |
— | — | @@ -379,7 +379,7 @@ |
380 | 380 | * @static |
381 | 381 | */ |
382 | 382 | public function addRelations( $field, $values, $logid ) { |
383 | | - if( empty($values) ) |
| 383 | + if( !strlen($field) || empty($values) ) |
384 | 384 | return false; // nothing |
385 | 385 | $data = array(); |
386 | 386 | foreach( $values as $value ) { |