Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php |
— | — | @@ -85,16 +85,15 @@ |
86 | 86 | $this->showImages(); |
87 | 87 | } else if( $this->deleteKey == 'logid' ) { |
88 | 88 | $this->showLogItems(); |
89 | | - return; // no logs for now |
90 | 89 | } |
91 | | - list($qc,$lim) = $this->getLogQueryCond(); |
| 90 | + $qc = $this->getLogQueryCond(); |
92 | 91 | # Show relevant lines from the deletion log |
93 | 92 | $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'delete' ) ) . "</h2>\n" ); |
94 | | - LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText(), '', $lim, $qc ); |
| 93 | + LogEventsList::showLogExtract( $wgOut, 'delete', $this->page->getPrefixedText(), '', 25, $qc ); |
95 | 94 | # Show relevant lines from the suppression log |
96 | 95 | if( $wgUser->isAllowed( 'suppressionlog' ) ) { |
97 | 96 | $wgOut->addHTML( "<h2>" . htmlspecialchars( LogPage::logName( 'suppress' ) ) . "</h2>\n" ); |
98 | | - LogEventsList::showLogExtract( $wgOut, 'suppress', $this->page->getPrefixedText(), '', $lim, $qc ); |
| 97 | + LogEventsList::showLogExtract( $wgOut, 'suppress', $this->page->getPrefixedText(), '', 25, $qc ); |
99 | 98 | } |
100 | 99 | } |
101 | 100 | |
— | — | @@ -121,9 +120,7 @@ |
122 | 121 | } |
123 | 122 | |
124 | 123 | private function getLogQueryCond() { |
125 | | - $ids = $safeIds = array(); |
126 | | - $limit = 25; // default |
127 | | - $conds = array( 'log_action' => 'revision' ); // revision delete logs |
| 124 | + $logAction = 'revision'; |
128 | 125 | switch( $this->deleteKey ) { |
129 | 126 | case 'oldid': |
130 | 127 | $ids = $this->oldids; |
— | — | @@ -137,25 +134,19 @@ |
138 | 135 | case 'fileid': |
139 | 136 | $ids = $this->fileids; |
140 | 137 | break; |
| 138 | + case 'logid': |
| 139 | + $ids = $this->logids; |
| 140 | + $logAction = 'event'; |
| 141 | + break; |
141 | 142 | default: // bad type? |
142 | | - return array($conds,$limit); |
| 143 | + return array(); |
143 | 144 | } |
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); |
| 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; |
160 | 151 | } |
161 | 152 | |
162 | 153 | private function secureOperation() { |
— | — | @@ -1541,18 +1532,41 @@ |
1542 | 1533 | $param, $items = array() ) |
1543 | 1534 | { |
1544 | 1535 | // Put things hidden from sysops in the oversight log |
1545 | | - $logtype = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ? |
| 1536 | + $logType = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ? |
1546 | 1537 | 'suppress' : 'delete'; |
1547 | | - $log = new LogPage( $logtype ); |
| 1538 | + // Log deletions show with a difference action message |
| 1539 | + $logAction = ( $param == 'logid' ) ? 'event' : 'revision'; |
| 1540 | + // Track what items changed here |
1548 | 1541 | $itemCSV = implode(',',$items); |
1549 | | - |
| 1542 | + // Add params for effected page and ids |
1550 | 1543 | if( $param == 'logid' ) { |
1551 | 1544 | $params = array( $itemCSV, "ofield={$obitfield}", "nfield={$nbitfield}" ); |
1552 | | - $log->addEntry( 'event', $title, $comment, $params ); |
1553 | 1545 | } else { |
1554 | | - // Add params for effected page and ids |
1555 | 1546 | $params = array( $param, $itemCSV, "ofield={$obitfield}", "nfield={$nbitfield}" ); |
1556 | | - $log->addEntry( 'revision', $title, $comment, $params ); |
1557 | 1547 | } |
| 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 ); |
1558 | 1553 | } |
| 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 | + } |
1559 | 1573 | } |
Index: trunk/phase3/includes/specials/SpecialBlockip.php |
— | — | @@ -450,13 +450,12 @@ |
451 | 451 | |
452 | 452 | # Set *_deleted fields if requested |
453 | 453 | if( $this->BlockHideName ) { |
454 | | - self::suppressUserName( $this->BlockAddress, $userId ); |
| 454 | + self::suppressUserName( $this->BlockAddress, $userId, $reasonstr ); |
455 | 455 | } |
456 | 456 | |
457 | | - if( $this->BlockWatchUser && |
458 | | - # Only show watch link when this is no range block |
459 | | - $block->mRangeStart == $block->mRangeEnd) { |
460 | | - $wgUser->addWatch ( Title::makeTitle( NS_USER, $this->BlockAddress ) ); |
| 457 | + # Only show watch link when this is no range block |
| 458 | + if( $this->BlockWatchUser && $block->mRangeStart == $block->mRangeEnd ) { |
| 459 | + $wgUser->addWatch( Title::makeTitle( NS_USER, $this->BlockAddress ) ); |
461 | 460 | } |
462 | 461 | |
463 | 462 | # Block constructor sanitizes certain block options on insert |
— | — | @@ -481,7 +480,20 @@ |
482 | 481 | } |
483 | 482 | } |
484 | 483 | |
485 | | - public static function suppressUserName( $name, $userId ) { |
| 484 | + public static function suppressUserName( $name, $userId, $reason = '' ) { |
| 485 | + $user = User::newFromName( $name, false ); |
| 486 | + # Delete the user pages that exists |
| 487 | + $title = $user->getUserPage(); |
| 488 | + if( ($id = $title->getArticleID(GAID_FOR_UPDATE)) ) { |
| 489 | + $article = new Article( $title ); |
| 490 | + $article->doDeleteArticle( $reason, true /*suppress*/, $id ); |
| 491 | + } |
| 492 | + # Delete the user talk pages that exists |
| 493 | + $title = $user->getTalkPage(); |
| 494 | + if( $id = $title->getArticleID(GAID_FOR_UPDATE) ) { |
| 495 | + $article = new Article( $title ); |
| 496 | + $article->doDeleteArticle( $reason, true /*suppress*/, $id ); |
| 497 | + } |
486 | 498 | $op = '|'; // bitwise OR |
487 | 499 | return self::setUsernameBitfields( $name, $userId, $op ); |
488 | 500 | } |