Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php |
— | — | @@ -85,15 +85,16 @@ |
86 | 86 | $this->showImages(); |
87 | 87 | } else if( $this->deleteKey == 'logid' ) { |
88 | 88 | $this->showLogItems(); |
| 89 | + return; // no logs for now |
89 | 90 | } |
90 | | - $qc = $this->getLogQueryCond(); |
| 91 | + list($qc,$lim) = $this->getLogQueryCond(); |
91 | 92 | # Show relevant lines from the deletion log |
92 | 93 | $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" ); |
93 | | - LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText(), '', 25, $qc ); |
| 94 | + LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText(), '', $lim, $qc ); |
94 | 95 | # Show relevant lines from the suppression log |
95 | 96 | if( $wgUser->isAllowed( 'suppressionlog' ) ) { |
96 | 97 | $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" ); |
97 | | - LogEventsList::showLogExtract( $wgOut, 'suppress', $this->page->getPrefixedText(), '', 25, $qc ); |
| 98 | + LogEventsList::showLogExtract( $wgOut, 'suppress', $this->page->getPrefixedText(), '', $lim, $qc ); |
98 | 99 | } |
99 | 100 | } |
100 | 101 | |
— | — | @@ -120,7 +121,9 @@ |
121 | 122 | } |
122 | 123 | |
123 | 124 | private function getLogQueryCond() { |
124 | | - $logAction = 'revision'; |
| 125 | + $ids = $safeIds = array(); |
| 126 | + $limit = 25; // default |
| 127 | + $conds = array( 'log_action' => 'revision' ); // revision delete logs |
125 | 128 | switch( $this->deleteKey ) { |
126 | 129 | case 'oldid': |
127 | 130 | $ids = $this->oldids; |
— | — | @@ -134,19 +137,25 @@ |
135 | 138 | case 'fileid': |
136 | 139 | $ids = $this->fileids; |
137 | 140 | break; |
138 | | - case 'logid': |
139 | | - $ids = $this->logids; |
140 | | - $logAction = 'event'; |
141 | | - break; |
142 | 141 | default: // bad type? |
143 | | - return array(); |
| 142 | + return array($conds,$limit); |
144 | 143 | } |
145 | | - // Revision delete logs for these item |
146 | | - $conds = array( 'log_action' => $logAction ); |
147 | | - $conds['ls_field'] = RevisionDeleter::getRelationType( $this->deleteKey ); |
148 | | - $conds['ls_value'] = $ids; |
149 | | - $conds[] = 'log_id = ls_log_id'; |
150 | | - return $conds; |
| 144 | + // Just get the whole log if there are a lot if items |
| 145 | + if( count($ids) > $limit ) |
| 146 | + return array($conds,$limit); |
| 147 | + // Digit chars only |
| 148 | + foreach( $ids as $id ) { |
| 149 | + if( preg_match( '/^\d+$/', $id, $m ) ) { |
| 150 | + $safeIds[] = $m[0]; |
| 151 | + } |
| 152 | + } |
| 153 | + // Format is <id1,id2,i3...> |
| 154 | + if( count($safeIds) ) { |
| 155 | + $conds[] = "log_params RLIKE '^{$this->deleteKey}.*(^|\n|,)(".implode('|',$safeIds).")(,|\n|$)'"; |
| 156 | + } else { |
| 157 | + $conds = array('1=0'); |
| 158 | + } |
| 159 | + return array($conds,$limit); |
151 | 160 | } |
152 | 161 | |
153 | 162 | private function secureOperation() { |
— | — | @@ -1532,41 +1541,18 @@ |
1533 | 1542 | $param, $items = array() ) |
1534 | 1543 | { |
1535 | 1544 | // Put things hidden from sysops in the oversight log |
1536 | | - $logType = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ? |
| 1545 | + $logtype = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ? |
1537 | 1546 | 'suppress' : 'delete'; |
1538 | | - // Log deletions show with a difference action message |
1539 | | - $logAction = ( $param == 'logid' ) ? 'event' : 'revision'; |
1540 | | - // Track what items changed here |
| 1547 | + $log = new LogPage( $logtype ); |
1541 | 1548 | $itemCSV = implode(',',$items); |
1542 | | - // Add params for effected page and ids |
| 1549 | + |
1543 | 1550 | if( $param == 'logid' ) { |
1544 | 1551 | $params = array( $itemCSV, "ofield={$obitfield}", "nfield={$nbitfield}" ); |
| 1552 | + $log->addEntry( 'event', $title, $comment, $params ); |
1545 | 1553 | } else { |
| 1554 | + // Add params for effected page and ids |
1546 | 1555 | $params = array( $param, $itemCSV, "ofield={$obitfield}", "nfield={$nbitfield}" ); |
| 1556 | + $log->addEntry( 'revision', $title, $comment, $params ); |
1547 | 1557 | } |
1548 | | - // Actually add the deletion log entry |
1549 | | - $log = new LogPage( $logType ); |
1550 | | - $logid = $log->addEntry( $logAction, $title, $comment, $params ); |
1551 | | - // Allow for easy searching of deletion log items for revision/log items |
1552 | | - $log->addRelations( self::getRelationType($param), $items, $logid ); |
1553 | 1558 | } |
1554 | | - |
1555 | | - // Get DB field name for URL param... |
1556 | | - // Future code for other things may also track |
1557 | | - // other types of revision-specific changes. |
1558 | | - public static function getRelationType( $param ) { |
1559 | | - switch( $param ) { |
1560 | | - case 'oldid': |
1561 | | - return 'rev_id'; |
1562 | | - case 'artimestamp': |
1563 | | - return 'rev_timestamp'; |
1564 | | - case 'oldimage': |
1565 | | - return 'oi_timestamp'; |
1566 | | - case 'fileid': |
1567 | | - return 'file_id'; |
1568 | | - case 'logid': |
1569 | | - return 'log_id'; |
1570 | | - } |
1571 | | - throw new MWException( "Bad log URL param type!" ); |
1572 | | - } |
1573 | 1559 | } |