r49378 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49377‎ | r49378 | r49379 >
Date:20:01, 10 April 2009
Author:aaron
Status:ok
Tags:
Comment:
(bug 18361) Suppression log should be in the UI language, not content language
Modified paths:
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)
  • /trunk/phase3/includes/LogPage.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRevisiondelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php
@@ -165,7 +165,9 @@
166166 }
167167 // Format is <id1,id2,i3...>
168168 if( count($safeIds) ) {
169 - $conds[] = "log_params RLIKE '(^|\n|,)(".implode('|',$safeIds).")(,|$)'";
 169+ $conds[] = "log_params RLIKE '(^|\n|,)(".implode('|',$safeIds).")(,|\n|$)'";
 170+ } else {
 171+ $conds = array('1=0');
170172 }
171173 return array($conds,$limit);
172174 }
@@ -678,9 +680,8 @@
679681 $pageLink = "<a href=\"{$url}\">{$date}</a>";
680682 }
681683
682 - $data = wfMsg( 'widthheight',
683 - $wgLang->formatNum( $file->getWidth() ),
684 - $wgLang->formatNum( $file->getHeight() ) ) .
 684+ $data = wfMsg( 'widthheight', $wgLang->formatNum( $file->getWidth() ),
 685+ $wgLang->formatNum( $file->getHeight() ) ) .
685686 ' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')';
686687 $data = htmlspecialchars( $data );
687688
@@ -707,9 +708,8 @@
708709 $del = ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
709710 }
710711
711 - $data = wfMsg( 'widthheight',
712 - $wgLang->formatNum( $file->getWidth() ),
713 - $wgLang->formatNum( $file->getHeight() ) ) .
 712+ $data = wfMsg( 'widthheight', $wgLang->formatNum( $file->getWidth() ),
 713+ $wgLang->formatNum( $file->getHeight() ) ) .
714714 ' (' . wfMsgExt( 'nbytes', 'parsemag', $wgLang->formatNum( $file->getSize() ) ) . ')';
715715 $data = htmlspecialchars( $data );
716716
@@ -1467,7 +1467,7 @@
14681468 * @param int $diff The xor of the old and new bitfields.
14691469 * @param array $arr The array to update.
14701470 */
1471 - function checkItem( $desc, $field, $diff, $new, &$arr ) {
 1471+ protected static function checkItem( $desc, $field, $diff, $new, &$arr ) {
14721472 if( $diff & $field ) {
14731473 $arr[ ( $new & $field ) ? 0 : 1 ][] = $desc;
14741474 }
@@ -1485,15 +1485,15 @@
14861486 * @param int $o The old bitfield.
14871487 * @return An array as described above.
14881488 */
1489 - function getChanges( $n, $o ) {
 1489+ protected static function getChanges( $n, $o ) {
14901490 $diff = $n ^ $o;
14911491 $ret = array( 0 => array(), 1 => array(), 2 => array() );
14921492 // Build bitfield changes in language
1493 - $this->checkItem( wfMsgForContent( 'revdelete-content' ),
 1493+ self::checkItem( wfMsgForContent( 'revdelete-content' ),
14941494 Revision::DELETED_TEXT, $diff, $n, $ret );
1495 - $this->checkItem( wfMsgForContent( 'revdelete-summary' ),
 1495+ self::checkItem( wfMsgForContent( 'revdelete-summary' ),
14961496 Revision::DELETED_COMMENT, $diff, $n, $ret );
1497 - $this->checkItem( wfMsgForContent( 'revdelete-uname' ),
 1497+ self::checkItem( wfMsgForContent( 'revdelete-uname' ),
14981498 Revision::DELETED_USER, $diff, $n, $ret );
14991499 // Restriction application to sysops
15001500 if( $diff & Revision::DELETED_RESTRICTED ) {
@@ -1513,15 +1513,12 @@
15141514 * @param int $count The number of effected revisions.
15151515 * @param int $nbitfield The new bitfield for the revision.
15161516 * @param int $obitfield The old bitfield for the revision.
1517 - * @param string $comment The comment associated with the change.
15181517 * @param bool $isForLog
15191518 */
1520 - function getLogMessage( $count, $nbitfield, $obitfield, $comment, $isForLog = false ) {
1521 - global $wgContLang;
1522 -
 1519+ public static function getLogMessage( $count, $nbitfield, $obitfield, $isForLog = false ) {
 1520+ global $wgLang;
15231521 $s = '';
1524 - $changes = $this->getChanges( $nbitfield, $obitfield );
1525 -
 1522+ $changes = self::getChanges( $nbitfield, $obitfield );
15261523 if( count( $changes[0] ) ) {
15271524 $s .= wfMsgForContent ( 'revdelete-hid', implode ( ', ', $changes[0] ) );
15281525 }
@@ -1532,15 +1529,9 @@
15331530 if( count( $changes[2] ) ) {
15341531 $s .= $s ? ' (' . $changes[2][0] . ')' : $changes[2][0];
15351532 }
1536 -
15371533 $msg = $isForLog ? 'logdelete-log-message' : 'revdelete-log-message';
1538 - $ret = wfMsgExt ( $msg, array( 'parsemag', 'content' ),
1539 - $s, $wgContLang->formatNum( $count ) );
 1534+ return wfMsgExt( $msg, array( 'parsemag', 'content' ), $s, $wgLang->formatNum($count) );
15401535
1541 - if( $comment ) $ret .= ": $comment";
1542 -
1543 - return $ret;
1544 -
15451536 }
15461537
15471538 /**
@@ -1561,16 +1552,15 @@
15621553 $logtype = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ?
15631554 'suppress' : 'delete';
15641555 $log = new LogPage( $logtype );
 1556+ $itemCSV = implode(',',$items);
15651557
1566 - $reason = $this->getLogMessage( $count, $nbitfield, $obitfield, $comment, $param == 'logid' );
1567 -
15681558 if( $param == 'logid' ) {
1569 - $params = array( implode( ',', $items) );
1570 - $log->addEntry( 'event', $title, $reason, $params );
 1559+ $params = array( $itemCSV, "ofield={$obitfield}", "nfield={$nbitfield}" );
 1560+ $log->addEntry( 'event', $title, $comment, $params );
15711561 } else {
15721562 // Add params for effected page and ids
1573 - $params = array( $param, implode( ',', $items) );
1574 - $log->addEntry( 'revision', $title, $reason, $params );
 1563+ $params = array( $param, $itemCSV, "ofield={$obitfield}", "nfield={$nbitfield}" );
 1564+ $log->addEntry( 'revision', $title, $comment, $params );
15751565 }
15761566 }
15771567 }
Index: trunk/phase3/includes/LogPage.php
@@ -201,6 +201,7 @@
202202 } else {
203203 $details = '';
204204 array_unshift( $params, $titleLink );
 205+ // User suppression
205206 if ( preg_match( '/^(block|suppress)\/(block|reblock)$/', $key ) ) {
206207 if ( $skin ) {
207208 $params[1] = '<span title="' . htmlspecialchars( $params[1] ). '">' .
@@ -210,6 +211,7 @@
211212 }
212213 $params[2] = isset( $params[2] ) ?
213214 self::formatBlockFlags( $params[2], is_null( $skin ) ) : '';
 215+ // Page protections
214216 } else if ( $type == 'protect' && count($params) == 3 ) {
215217 $details .= " {$params[1]}"; // restrictions and expiries
216218 if( $params[2] ) {
@@ -219,6 +221,7 @@
220222 $details .= ' ['.wfMsgForContent('protect-summary-cascade').']';
221223 }
222224 }
 225+ // Page moves
223226 } else if ( $type == 'move' && count( $params ) == 3 ) {
224227 if( $params[2] ) {
225228 if ( $skin ) {
@@ -227,6 +230,18 @@
228231 $details .= ' [' . wfMsgForContent( 'move-redirect-suppressed' ) . ']';
229232 }
230233 }
 234+ // Revision deletion
 235+ } else if ( preg_match( '/^(delete|suppress)\/revision$/', $key ) && count( $params ) == 5 ) {
 236+ $count = substr_count( $params[1], ',' ) + 1; // revisions
 237+ $ofield = intval( substr( $params[3], 7 ) ); // <ofield=x>
 238+ $nfield = intval( substr( $params[4], 7 ) ); // <nfield=x>
 239+ $details .= ': '.RevisionDeleter::getLogMessage( $count, $nfield, $ofield, false );
 240+ // Log deletion
 241+ } else if ( preg_match( '/^(delete|suppress)\/event$/', $key ) && count( $params ) == 4 ) {
 242+ $count = substr_count( $params[1], ',' ) + 1; // log items
 243+ $ofield = intval( substr( $params[2], 7 ) ); // <ofield=x>
 244+ $nfield = intval( substr( $params[3], 7 ) ); // <nfield=x>
 245+ $details .= ': '.RevisionDeleter::getLogMessage( $count, $nfield, $ofield, true );
231246 }
232247 $rv = wfMsgReal( $wgLogActions[$key], $params, true, !$skin ) . $details;
233248 }
Index: trunk/phase3/includes/LogEventsList.php
@@ -282,7 +282,7 @@
283283 'mergepoint' => $paramArray[1] ) ) ) . ')';
284284 // If an edit was hidden from a page give a review link to the history
285285 } else if( self::typeAction($row,array('delete','suppress'),'revision','deleterevision') ) {
286 - if( count($paramArray) == 2 ) {
 286+ if( count($paramArray) >= 2 ) {
287287 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
288288 // Different revision types use different URL params...
289289 $key = $paramArray[0];
@@ -304,7 +304,7 @@
305305 }
306306 // Hidden log items, give review link
307307 } else if( self::typeAction($row,array('delete','suppress'),'event','deleterevision') ) {
308 - if( count($paramArray) == 1 ) {
 308+ if( count($paramArray) >= 1 ) {
309309 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
310310 // $paramArray[1] is a CVS of the IDs
311311 $Ids = explode( ',', $paramArray[0] );

Status & tagging log