r98365 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98364‎ | r98365 | r98366 >
Date:20:28, 28 September 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Followup r98135
* Added gender parameter to newuserlog-create2-entry
* Hide old comments (for all log types!)
* logentry-newusers-newusers needs a message after all
* Move user tool links away from the action links and drop the User: prefix from create2
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/includes/logging/LogFormatter.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messageTypes.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messageTypes.inc
@@ -179,7 +179,6 @@
180180 'unusedtemplates-summary',
181181 'fewestrevisions-summary',
182182 'upload-summary',
183 - 'logentry-newusers-newusers',
184183 'wantedtemplates-summary',
185184 'activeusers-summary',
186185 'search-summary',
Index: trunk/phase3/includes/Setup.php
@@ -316,7 +316,7 @@
317317 $wgLogNames['newusers'] = 'newuserlogpage';
318318 $wgLogHeaders['newusers'] = 'newuserlogpagetext';
319319 # newusers, create, create2, autocreate
320 - $wgLogActionsHandlers['newusers/*'] = 'LogFormatter';
 320+ $wgLogActionsHandlers['newusers/*'] = 'NewUsersLogFormatter';
321321 }
322322
323323 if ( $wgCookieSecure === 'detect' ) {
Index: trunk/phase3/includes/logging/LogFormatter.php
@@ -226,26 +226,8 @@
227227 */
228228 public function getPerformerElement() {
229229 $performer = $this->entry->getPerformer();
 230+ $element = $this->makeUserLink( $performer );
230231
231 - if ( $this->plaintext ) {
232 - $element = $performer->getName();
233 - } else {
234 - $element = Linker::userLink(
235 - $performer->getId(),
236 - $performer->getName()
237 - );
238 -
239 - if ( $this->linkFlood ) {
240 - $element .= Linker::userToolLinks(
241 - $performer->getId(),
242 - $performer->getName(),
243 - true, // Red if no edits
244 - 0, // Flags
245 - $performer->getEditCount()
246 - );
247 - }
248 - }
249 -
250232 if ( $this->entry->isDeleted( LogPage::DELETED_USER ) ) {
251233 $element = self::getRestrictedElement( 'rev-deleted-user' );
252234 }
@@ -296,6 +278,28 @@
297279 ->title( $this->context->getTitle() );
298280 }
299281
 282+ protected function makeUserLink( User $user ) {
 283+ if ( $this->plaintext ) {
 284+ $element = $user->getName();
 285+ } else {
 286+ $element = Linker::userLink(
 287+ $user->getId(),
 288+ $user->getName()
 289+ );
 290+
 291+ if ( $this->linkFlood ) {
 292+ $element .= Linker::userToolLinks(
 293+ $user->getId(),
 294+ $user->getName(),
 295+ true, // Red if no edits
 296+ 0, // Flags
 297+ $user->getEditCount()
 298+ );
 299+ }
 300+ }
 301+ return $element;
 302+ }
 303+
300304 }
301305
302306 /**
@@ -455,4 +459,35 @@
456460 $newParams[3] = Message::rawParam( $revlink );
457461 return $newParams;
458462 }
 463+}
 464+
 465+/**
 466+ * This class formats new user log entries.
 467+ * @since 1.19
 468+ */
 469+class NewUsersLogFormatter extends LogFormatter {
 470+ protected function getMessageParameters() {
 471+ $params = parent::getMessageParameters();
 472+ if ( $this->entry->getSubtype() === 'create2' ) {
 473+ if ( isset( $params[3] ) ) {
 474+ $target = User::newFromId( $params[3] );
 475+ } else {
 476+ $target = User::newFromName( $this->entry->getTarget()->getText(), false );
 477+ }
 478+ $params[2] = Message::rawParam( $this->makeUserLink( $target ) );
 479+ $params[3] = $target->getName();
 480+ }
 481+ return $params;
 482+ }
 483+
 484+ public function getComment() {
 485+ $subtype = $this->entry->getSubtype();
 486+ $timestamp = wfTimestamp( TS_MW, $this->entry->getTimestamp() );
 487+ if ( $timestamp < '20080129000000' ) {
 488+ # Suppress $comment from old entries (before 2008-01-29),
 489+ # not needed and can contain incorrect links
 490+ return '';
 491+ }
 492+ return parent::getComment();
 493+ }
459494 }
\ No newline at end of file
Index: trunk/phase3/includes/LogEventsList.php
@@ -486,19 +486,6 @@
487487 array( 'known', 'noclasses' )
488488 ) . ')';
489489 }
490 - // Self-created users
491 - } elseif( self::typeAction( $row, 'newusers', 'create2' ) ) {
492 - if( isset( $paramArray[0] ) ) {
493 - $revert = Linker::userToolLinks( $paramArray[0], $title->getDBkey(), true );
494 - } else {
495 - # Fall back to a blue contributions link
496 - $revert = Linker::userToolLinks( 1, $title->getDBkey() );
497 - }
498 - if( wfTimestamp( TS_MW, $row->log_timestamp ) < '20080129000000' ) {
499 - # Suppress $comment from old entries (before 2008-01-29),
500 - # not needed and can contain incorrect links
501 - $comment = '';
502 - }
503490 // Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters.
504491 } else {
505492 wfRunHooks( 'LogLine', array( $row->log_type, $row->log_action, $title, $paramArray,
Index: trunk/phase3/includes/AutoLoader.php
@@ -545,6 +545,7 @@
546546 'LogFormatter' => 'includes/logging/LogFormatter.php',
547547 'ManualLogEntry' => 'includes/logging/LogEntry.php',
548548 'MoveLogFormatter' => 'includes/logging/LogFormatter.php',
 549+ 'NewUsersLogFormatter' => 'includes/logging/LogFormatter.php',
549550 'PatrolLog' => 'includes/logging/PatrolLog.php',
550551 'PatrolLogFormatter' => 'includes/logging/LogFormatter.php',
551552 'RCDatabaseLogEntry' => 'includes/logging/LogEntry.php',
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -4653,9 +4653,9 @@
46544654 'logentry-move-move_redir-noredirect' => '$1 {{GENDER:$2|moved}} page $3 to $4 over a redirect without leaving a redirect',
46554655 'logentry-patrol-patrol' => '$1 {{GENDER:$2|marked}} revision $4 of page $3 patrolled',
46564656 'logentry-patrol-patrol-auto' => '$1 automatically {{GENDER:$2|marked}} revision $4 of page $3 patrolled',
4657 -'logentry-newusers-newusers' => '', # do not translate or duplicate this message to other languages
 4657+'logentry-newusers-newusers' => '$1 {{GENDER:$2|created}} a user account',
46584658 'logentry-newusers-create' => '$1 {{GENDER:$2|created}} a user account',
4659 -'logentry-newusers-create2' => '$1 {{GENDER:$2|created}} a user account $3',
 4659+'logentry-newusers-create2' => '$1 {{GENDER:$2|created}} {{GENDER:$4|a user account}} $3',
46604660 'logentry-newusers-autocreate' => 'Account $1 was {{GENDER:$2|created}} automatically',
46614661 'newuserlog-byemail' => 'password sent by e-mail',
46624662

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98135Converted display part of new user log to new systemnikerabbit15:12, 26 September 2011

Status & tagging log