r112073 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112072‎ | r112073 | r112074 >
Date:00:54, 22 February 2012
Author:reedy
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.19wmf1 (modified) (history)
  • /branches/wmf/1.19wmf1/includes (modified) (history)
  • /branches/wmf/1.19wmf1/includes/RecentChange.php (modified) (history)
  • /branches/wmf/1.19wmf1/includes/logging/LogEntry.php (modified) (history)
  • /branches/wmf/1.19wmf1/includes/logging/LogFormatter.php (modified) (history)
  • /branches/wmf/1.19wmf1/includes/logging/LogPage.php (modified) (history)
  • /branches/wmf/1.19wmf1/languages (modified) (history)
  • /branches/wmf/1.19wmf1/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.19wmf1/languages/messages/MessagesEn.php
@@ -4708,6 +4708,32 @@
47094709 'logentry-newusers-autocreate' => 'Account $1 was created automatically',
47104710 'newuserlog-byemail' => 'password sent by e-mail',
47114711
 4712+# For IRC, see bug 34508. Do not change
 4713+'revdelete-logentry' => 'changed revision visibility of "[[$1]]"',
 4714+'logdelete-logentry' => 'changed event visibility of "[[$1]]"',
 4715+'revdelete-content' => 'content',
 4716+'revdelete-summary' => 'edit summary',
 4717+'revdelete-uname' => 'username',
 4718+'revdelete-hid' => 'hid $1',
 4719+'revdelete-unhid' => 'unhid $1',
 4720+'revdelete-log-message' => '$1 for $2 {{PLURAL:$2|revision|revisions}}',
 4721+'logdelete-log-message' => '$1 for $2 {{PLURAL:$2|event|events}}',
 4722+'deletedarticle' => 'deleted "[[$1]]"',
 4723+'suppressedarticle' => 'suppressed "[[$1]]"',
 4724+'undeletedarticle' => 'restored "[[$1]]"',
 4725+'patrol-log-line' => 'marked $1 of $2 patrolled $3',
 4726+'patrol-log-auto' => '(automatic)',
 4727+'patrol-log-diff' => 'revision $1',
 4728+'1movedto2' => 'moved [[$1]] to [[$2]]',
 4729+'1movedto2_redir' => 'moved [[$1]] to [[$2]] over redirect',
 4730+'move-redirect-suppressed' => 'redirect suppressed',
 4731+'newuserlog-byemail' => 'password sent by e-mail',
 4732+'newuserlog-create-entry' => 'New user account',
 4733+'newuserlog-create2-entry' => 'created new account $1',
 4734+'newuserlog-autocreate-entry' => 'Account created automatically',
 4735+'suppressedarticle' => 'suppressed "[[$1]]"',
 4736+'deletedarticle' => 'deleted "[[$1]]"',
 4737+
47124738 # Feedback
47134739 'feedback-bugornote' => 'If you are ready to describe a technical problem in detail please [$1 report a bug].
47144740 Otherwise, you can use the easy form below. Your comment will be added to the page "[$3 $2]", along with your username and what browser you are using.',
Property changes on: branches/wmf/1.19wmf1/languages
___________________________________________________________________
Modified: svn:mergeinfo
47154741 Merged /trunk/phase3/languages:r112049,112061-112063,112065-112066,112070-112071
Index: branches/wmf/1.19wmf1/includes/RecentChange.php
@@ -503,10 +503,11 @@
504504 * @param $logComment
505505 * @param $params
506506 * @param $newId int
 507+ * @param $actionCommentIRC string
507508 * @return bool
508509 */
509 - public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip='', $type,
510 - $action, $target, $logComment, $params, $newId=0 )
 510+ public static function notifyLog( $timestamp, &$title, &$user, $actionComment, $ip, $type,
 511+ $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='' )
511512 {
512513 global $wgLogRestrictions;
513514 # Don't add private logs to RC!
@@ -514,7 +515,7 @@
515516 return false;
516517 }
517518 $rc = self::newLogEntry( $timestamp, $title, $user, $actionComment, $ip, $type, $action,
518 - $target, $logComment, $params, $newId );
 519+ $target, $logComment, $params, $newId, $actionCommentIRC );
519520 $rc->save();
520521 return true;
521522 }
@@ -531,10 +532,11 @@
532533 * @param $logComment
533534 * @param $params
534535 * @param $newId int
 536+ * @param $actionCommentIRC string
535537 * @return RecentChange
536538 */
537 - public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip='',
538 - $type, $action, $target, $logComment, $params, $newId=0 ) {
 539+ public static function newLogEntry( $timestamp, &$title, &$user, $actionComment, $ip,
 540+ $type, $action, $target, $logComment, $params, $newId=0, $actionCommentIRC='' ) {
539541 global $wgRequest;
540542 if( !$ip ) {
541543 $ip = $wgRequest->getIP();
@@ -575,6 +577,7 @@
576578 'prefixedDBkey' => $title->getPrefixedDBkey(),
577579 'lastTimestamp' => 0,
578580 'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage
 581+ 'actionCommentIRC' => $actionCommentIRC
579582 );
580583 return $rc;
581584 }
@@ -712,7 +715,7 @@
713716
714717 if ( $this->mAttribs['rc_type'] == RC_LOG ) {
715718 $targetText = $this->getTitle()->getPrefixedText();
716 - $comment = self::cleanupForIRC( str_replace( "[[$targetText]]", "[[\00302$targetText\00310]]", $this->mExtra['actionComment'] ) );
 719+ $comment = self::cleanupForIRC( str_replace( "[[$targetText]]", "[[\00302$targetText\00310]]", $this->mExtra['actionCommentIRC'] ) );
717720 $flag = $this->mAttribs['rc_log_action'];
718721 } else {
719722 $comment = self::cleanupForIRC( $this->mAttribs['rc_comment'] );
Index: branches/wmf/1.19wmf1/includes/logging/LogEntry.php
@@ -461,14 +461,15 @@
462462 $this->getTimestamp(),
463463 $logpage,
464464 $user,
465 - $formatter->getPlainActionText(), // Used for IRC feeds
 465+ $formatter->getPlainActionText(),
466466 $user->isAnon() ? $user->getName() : '',
467467 $this->getType(),
468468 $this->getSubtype(),
469469 $this->getTarget(),
470470 $this->getComment(),
471471 serialize( (array) $this->getParameters() ),
472 - $newId
 472+ $newId,
 473+ $formatter->getIRCActionComment() // Used for IRC feeds
473474 );
474475
475476 if ( $to === 'rc' || $to === 'rcandudp' ) {
Index: branches/wmf/1.19wmf1/includes/logging/LogFormatter.php
@@ -77,6 +77,8 @@
7878 */
7979 protected $plaintext = false;
8080
 81+ protected $irctext = false;
 82+
8183 protected function __construct( LogEntry $entry ) {
8284 $this->entry = $entry;
8385 $this->context = RequestContext::getMain();
@@ -141,6 +143,132 @@
142144 }
143145
144146 /**
 147+ * Even uglier hack to maintain backwards compatibilty with IRC bots
 148+ * (bug 34508).
 149+ * @see getActionText()
 150+ * @return string text
 151+ */
 152+ public function getIRCActionComment() {
 153+ $actionComment = $this->getIRCActionText();
 154+ $comment = $this->entry->getComment();
 155+
 156+ if ( $comment != '' ) {
 157+ if ( $actionComment == '' ) {
 158+ $actionComment = $comment;
 159+ } else {
 160+ $actionComment .= wfMsgForContent( 'colon-separator' ) . $comment;
 161+ }
 162+ }
 163+
 164+ return $actionComment;
 165+ }
 166+
 167+ /**
 168+ * Even uglier hack to maintain backwards compatibilty with IRC bots
 169+ * (bug 34508).
 170+ * @see getActionText()
 171+ * @return string text
 172+ */
 173+ public function getIRCActionText() {
 174+ $this->plaintext = true;
 175+ $text = $this->getActionText();
 176+
 177+ // wfRunHooks( 'LogEntry::publish', array( $this, $formatter, &$actionText ) );
 178+ // function efLegacyLogsIrcFormat( $entry, $formatter, &$text ) {
 179+
 180+ $entry = $this->entry;
 181+ $parameters = $entry->getParameters();
 182+ // Text of title the action is aimed at.
 183+ $target = $entry->getTarget()->getText() ;
 184+ $text = null;
 185+ switch( $entry->getType() ) {
 186+ case 'move':
 187+ switch( $entry->getSubtype() ) {
 188+ case 'move':
 189+ $movesource = $parameters['4::target'];
 190+ $text = wfMsg( '1movedto2', $target, $movesource );
 191+ break;
 192+ case 'move_redir':
 193+ $movesource = $parameters['4::target'];
 194+ $text = wfMsg( '1movedto2_redir', $target, $movesource );
 195+ break;
 196+ case 'move-noredirect':
 197+ break;
 198+ case 'move_redir-noredirect':
 199+ break;
 200+ }
 201+ break;
 202+
 203+ case 'delete':
 204+ switch( $entry->getSubtype() ) {
 205+ case 'delete':
 206+ $text = wfMsg( 'deletedarticle', $target );
 207+ break;
 208+ case 'restore':
 209+ $text = wfMsg( 'undeletedarticle', $target );
 210+ break;
 211+ //case 'revision': // Revision deletion
 212+ //case 'event': // Log deletion
 213+ // see https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/LogPage.php?&pathrev=97044&r1=97043&r2=97044
 214+ //default:
 215+ }
 216+ break;
 217+
 218+ case 'patrol':
 219+ // https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/PatrolLog.php?&pathrev=97495&r1=97494&r2=97495
 220+ // Create a diff link to the patrolled revision
 221+ $diffLink = Linker::link(
 222+ $target,
 223+ htmlspecialchars( wfMsg( 'patrol-log-diff', $parameters['4::curid']) ),
 224+ array(),
 225+ /*query parameters */ array( 'oldid'=>$parameters['4::curid'], 'diff' => 'prev' ),
 226+ array( 'known', 'noclasses' )
 227+ );
 228+ $link = Linker::link( $entry->getTarget() );
 229+
 230+ if ( $entry->getSubtype() === 'patrol' ) {
 231+ // 'patrol-log-line' => 'marked $1 of $2 patrolled $3',
 232+ // 'logentry-irc-patrol-patrol' => '$1 marked revision $4 of page $3 patrolled',
 233+
 234+ $text = wfMsg( 'patrol-log-line', $diffLink, $link );
 235+ } elseif ( $entry->getSubtype() === 'patrol-auto' ) {
 236+ // 'patrol-log-line' => 'marked $1 of $2 patrolled $3',
 237+ // 'patrol-log-auto' => '(automatic)',
 238+ // 'logentry-irc-patrol-patrol-auto' => '$1 automatically marked revision $4 of page $3 patrolled',
 239+ // How is this done with old messages? Some abomination to man?
 240+ $text = wfMsg( 'patrol-log-line-auto', $diffLink, $link );
 241+ } else {
 242+ // broken??
 243+ }
 244+ break;
 245+
 246+ case 'newusers':
 247+ switch( $entry->getSubtype() ) {
 248+ case 'newusers':
 249+ case 'create':
 250+ $text = wfMsg( 'newuserlog-create-entry' /* no params */ );
 251+ break;
 252+ case 'create2':
 253+ $text = wfMsg( 'newuserlog-create2-entry', $target );
 254+ break;
 255+ case 'autocreate':
 256+ $text = wfMsg( 'newuserlog-autocreate-entry' /* no params */ );
 257+ break;
 258+ }
 259+ break;
 260+
 261+ // case 'suppress' --private log -- aaron (sign your messages so we know who to blame in a few years :-D)
 262+ // default:
 263+ }
 264+ if( is_null( $text ) ) {
 265+ $text = $this->getPlainActionText();
 266+ }
 267+
 268+ $this->plaintext = false;
 269+ return $text;
 270+ }
 271+
 272+ /**
145273 * Gets the log action, including username.
146274 * @return string HTML
147275 */
@@ -183,8 +311,8 @@
184312 protected function getMessageKey() {
185313 $type = $this->entry->getType();
186314 $subtype = $this->entry->getSubtype();
187 - $key = "logentry-$type-$subtype";
188 - return $key;
 315+
 316+ return "logentry-$type-$subtype";
189317 }
190318
191319 /**
Index: branches/wmf/1.19wmf1/includes/logging/LogPage.php
@@ -100,7 +100,7 @@
101101 RecentChange::notifyLog(
102102 $now, $titleObj, $this->doer, $this->getRcComment(), '',
103103 $this->type, $this->action, $this->target, $this->comment,
104 - $this->params, $newId
 104+ $this->params, $newId, $this->getRcCommentIRC()
105105 );
106106 } elseif( $this->sendToUDP ) {
107107 # Don't send private logs to UDP
@@ -114,7 +114,7 @@
115115 $rc = RecentChange::newLogEntry(
116116 $now, $titleObj, $this->doer, $this->getRcComment(), '',
117117 $this->type, $this->action, $this->target, $this->comment,
118 - $this->params, $newId
 118+ $this->params, $newId, $this->getRcCommentIRC()
119119 );
120120 $rc->notifyRC2UDP();
121121 }
@@ -141,6 +141,25 @@
142142 }
143143
144144 /**
 145+ * Get the RC comment from the last addEntry() call for IRC
 146+ *
 147+ * @return string
 148+ */
 149+ public function getRcCommentIRC() {
 150+ $rcComment = $this->ircActionText;
 151+
 152+ if( $this->comment != '' ) {
 153+ if ( $rcComment == '' ) {
 154+ $rcComment = $this->comment;
 155+ } else {
 156+ $rcComment .= wfMsgForContent( 'colon-separator' ) . $this->comment;
 157+ }
 158+ }
 159+
 160+ return $rcComment;
 161+ }
 162+
 163+ /**
145164 * Get the comment from the last addEntry() call
146165 */
147166 public function getComment() {
@@ -461,6 +480,7 @@
462481 $formatter->setContext( $context );
463482
464483 $this->actionText = $formatter->getPlainActionText();
 484+ $this->ircActionText = $formatter->getIRCActionText();
465485
466486 return $this->saveContent();
467487 }
Property changes on: branches/wmf/1.19wmf1/includes
___________________________________________________________________
Modified: svn:mergeinfo
468488 Merged /trunk/phase3/includes:r112045-112046,112049,112061-112063,112065-112066,112070-112071
Property changes on: branches/wmf/1.19wmf1
___________________________________________________________________
Modified: svn:mergeinfo
469489 Merged /trunk/phase3:r112045-112046,112049,112061-112063,112065-112066,112070-112071

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r112045First merge of the rest of the code from bug 34508 patch 1 and patch 3reedy21:26, 21 February 2012
r112046consistently use $entryreedy21:27, 21 February 2012
r112049Effectively revert r112042...reedy21:54, 21 February 2012
r112061Bug 34508 - [Regression] IRC string output for log messages no longer compatible...reedy23:38, 21 February 2012
r112062Separate out an IRC actionText field for RecentChange. The two are currently ...aaron23:39, 21 February 2012
r112063r112062: swap the getPlainActionText() for IRC with new getIRCActionText() fu...aaron23:42, 21 February 2012
r112065r112062: updated LogEntry publish() function tooaaron23:51, 21 February 2012
r112066Move parameters were backwards...reedy00:00, 22 February 2012
r112070Made use of new getIRCActionComment() function so that comments are back in I...aaron00:26, 22 February 2012
r112071Made getIRCActionText() public again...since the old LogPage still uses it, ughaaron00:36, 22 February 2012

Status & tagging log