r32836 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32835‎ | r32836 | r32837 >
Date:06:30, 6 April 2008
Author:amidaniel
Status:old
Tags:
Comment:
Make rev_deleted log entries more intelligible for those of us who "don't speak bitfield".
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/SpecialRevisiondelete.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SpecialRevisiondelete.php
@@ -1333,8 +1333,93 @@
13341334 // Extensions that require referencing previous revisions may need this
13351335 wfRunHooks( 'ArticleRevisionVisiblitySet', array( &$title ) );
13361336 }
1337 -
 1337+
13381338 /**
 1339+ * Checks for a change in the bitfield for a certain option and updates the
 1340+ * provided array accordingly.
 1341+ *
 1342+ * @param String $desc Description to add to the array if the option was
 1343+ * enabled / disabled.
 1344+ * @param int $field The bitmask describing the single option.
 1345+ * @param int $diff The xor of the old and new bitfields.
 1346+ * @param array $arr The array to update.
 1347+ */
 1348+ function checkItem ( $desc, $field, $diff, $new, $arr )
 1349+ {
 1350+ if ( $diff & $field ) {
 1351+ $arr [ ( $new & $field ) ? 0 : 1 ][] = $desc;
 1352+ }
 1353+ }
 1354+
 1355+ /**
 1356+ * Gets an array describing the changes made to the visibilit of the revision.
 1357+ * If the resulting array is $arr, then $arr[0] will contain an array of strings
 1358+ * describing the items that were hidden, $arr[2] will contain an array of strings
 1359+ * describing the items that were unhidden, and $arr[3] will contain an array with
 1360+ * a single string, which can be one of "applied restrictions to sysops",
 1361+ * "removed restrictions from sysops", or null.
 1362+ *
 1363+ * @param int $n The new bitfield.
 1364+ * @param int $o The old bitfield.
 1365+ * @return An array as described above.
 1366+ */
 1367+ function getChanges ( $n, $o )
 1368+ {
 1369+ $diff = $n ^ $o;
 1370+ $ret = array ( 0 => array(), 1 => array(), 2 => array() );
 1371+
 1372+ $this->checkItem ( wfMsg ( 'revdelete-content' ), 1, $diff, $n, &$ret );
 1373+ $this->checkItem ( wfMsg ( 'revdelete-summary' ), 2, $diff, $n, &$ret );
 1374+ $this->checkItem ( wfMsg ( 'revdelete-uname' ), 4, $diff, $n, &$ret );
 1375+
 1376+ // Restriction application to sysops
 1377+ if ( $diff & 8 ) {
 1378+ if ( $n & 8 )
 1379+ $ret[2][] = wfMsg ( 'revdelete-restricted' );
 1380+ else
 1381+ $ret[2][] = wfMsg ( 'revdelete-unrestricted' );
 1382+ }
 1383+
 1384+ return $ret;
 1385+ }
 1386+
 1387+ /**
 1388+ * Gets a log message to describe the given revision visibility change. This
 1389+ * message will be of the form "[hid {content, edit summary, username}];
 1390+ * [unhid {...}][applied restrictions to sysops] for $count revisions: $comment".
 1391+ *
 1392+ * @param int $count The number of effected revisions.
 1393+ * @param int $nbitfield The new bitfield for the revision.
 1394+ * @param int $obitfield The old bitfield for the revision.
 1395+ * @param String $comment The comment associated with the change.
 1396+ */
 1397+ function getLogMessage ( $count, $nbitfield, $obitfield, $comment )
 1398+ {
 1399+ $s = '';
 1400+ $changes = $this->getChanges( $nbitfield, $obitfield );
 1401+
 1402+ if ( count ( $changes[0] ) ) {
 1403+ $s .= wfMsg ( 'revdelete-hid', implode ( ', ', $changes[0] ) );
 1404+ }
 1405+
 1406+ if ( count ( $changes[1] ) ) {
 1407+ if ($s) $s .= '; ';
 1408+
 1409+ $s .= wfMsg ( 'revdelete-unhid', implode ( ', ', $changes[1] ) );
 1410+ }
 1411+
 1412+ if ( count ( $changes[2] )) {
 1413+ if ($s)
 1414+ $s .= ' (' . $changes[2][0] . ')';
 1415+ else
 1416+ $s = $changes[2][0];
 1417+ }
 1418+
 1419+ return wfMsg ( 'revdelete-log-message', $s, $count, $comment );
 1420+
 1421+ }
 1422+
 1423+ /**
13391424 * Record a log entry on the action
13401425 * @param Title $title, page where item was removed from
13411426 * @param int $count the number of revisions altered for this page
@@ -1349,17 +1434,16 @@
13501435 // Put things hidden from sysops in the oversight log
13511436 $logtype = ( ($nbitfield | $obitfield) & Revision::DELETED_RESTRICTED ) ? 'suppress' : 'delete';
13521437 $log = new LogPage( $logtype );
 1438+
 1439+ $reason = $this->getLogMessage ( $count, $nbitfield, $obitfield, $comment );
 1440+
13531441 // FIXME: do this better
13541442 if( $param=='logid' ) {
13551443 $params = array( implode( ',', $items) );
1356 - $reason = wfMsgExt('logdelete-logaction', array('parsemag'), $count, $nbitfield );
1357 - if($comment) $reason .= ": $comment";
13581444 $log->addEntry( 'event', $title, $reason, $params );
13591445 } else {
13601446 // Add params for effected page and ids
13611447 $params = array( $target->getPrefixedText(), $param, implode( ',', $items) );
1362 - $reason = wfMsgExt('revdelete-logaction', array('parsemag'), $count, $nbitfield );
1363 - if($comment) $reason .= ": $comment";
13641448 $log->addEntry( 'revision', $title, $reason, $params );
13651449 }
13661450 }
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1210,14 +1210,22 @@
12111211 'revdelete-submit' => 'Apply to selected revision',
12121212 'revdelete-logentry' => 'changed revision visibility of [[$1]]',
12131213 'logdelete-logentry' => 'changed event visibility of [[$1]]',
1214 -'revdelete-logaction' => '$1 {{PLURAL:$1|revision|revisions}} set to mode $2',
1215 -'logdelete-logaction' => '$1 {{PLURAL:$1|event|events}} set to mode $2',
12161214 'revdelete-success' => "'''Revision visibility successfully set.'''",
12171215 'logdelete-success' => "'''Log visibility successfully set.'''",
12181216 'revdel-restore' => 'Change visiblity',
12191217 'pagehist' => 'Page history',
12201218 'deletedhist' => 'Deleted history',
12211219
 1220+# Revision deletion - log messages
 1221+'revdelete-content' => 'content',
 1222+'revdelete-summary' => 'edit summary',
 1223+'revdelete-uname' => 'username',
 1224+'revdelete-restricted' => 'applied restrictions to sysops',
 1225+'revdelete-unrestricted' => 'removed restrictions for sysops',
 1226+'revdelete-hid' => 'hid $1',
 1227+'revdelete-unhid' => 'unhid $1',
 1228+'revdelete-log-message' => '$1 for $2 {{PLURAL:$2|revisions|revision}}: $3',
 1229+
12221230 # Suppression log
12231231 'suppressionlog' => 'Suppression log',
12241232 'suppressionlogtext' => 'Below is a list of the most recent deletions and blocks involving content hidden from sysops. See the [[Special:Ipblocklist|IP block list]] for the list of currently operational bans and blocks.',
Index: trunk/phase3/RELEASE-NOTES
@@ -62,6 +62,7 @@
6363 * (bug 13450) Email confirmation can now be canceled before the expiration
6464 * (bug 13490) Show upload/file size limit on upload form
6565 * Redesign of Special:Userrights
 66+* Make rev_deleted log entries more intelligible.
6667
6768 === Bug fixes in 1.13 ===
6869

Follow-up revisions

RevisionCommit summaryAuthorDate
r32843* Updated messages.inc per r32836...ialex09:04, 6 April 2008

Status & tagging log