r83827 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83826‎ | r83827 | r83828 >
Date:15:14, 13 March 2011
Author:happy-melon
Status:resolved
Tags:
Comment:
Follow-up r83825: fix Block::parseTarget to recognise autoblocks separately, and change Block::getRedactedName() to run the string through a system message for localisation
Modified paths:
  • /trunk/phase3/includes/Block.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -2045,6 +2045,7 @@
20462046 'whatlinkshere-filters',
20472047 ),
20482048 'block' => array(
 2049+ 'autoblockid',
20492050 'blockip',
20502051 'blockip-title',
20512052 'blockip-legend',
Index: trunk/phase3/includes/Block.php
@@ -758,13 +758,17 @@
759759
760760 /**
761761 * Get the block name, but with autoblocked IPs hidden as per standard privacy policy
762 - * @return String
 762+ * @return String, text is escaped
763763 */
764764 public function getRedactedName() {
765765 if ( $this->mAuto ) {
766 - return '#' . $this->mId;
 766+ return HTML::rawElement(
 767+ 'span',
 768+ array( 'class' => 'mw-autoblockid' ),
 769+ wfMessage( 'autoblockid', $this->mId )
 770+ );
767771 } else {
768 - return $this->mAddress;
 772+ return htmlspecialchars( $this->mAddress );
769773 }
770774 }
771775
@@ -989,10 +993,20 @@
990994 }
991995
992996 /**
993 - * Get the target and target type for this particular Block
 997+ * Get the target and target type for this particular Block. Note that for autoblocks,
 998+ * this returns the unredacted name; frontend functions need to call $block->getRedactedName()
 999+ * in this situation.
9941000 * @return array( User|String, Block::TYPE_ constant )
 1001+ * FIXME: this should be an integral part of the Block member variables
9951002 */
9961003 public function getTargetAndType(){
997 - return self::parseTarget( $this->mAddress );
 1004+ list( $target, $type ) = self::parseTarget( $this->mAddress );
 1005+
 1006+ # Check whether it's an autoblock
 1007+ if( $type == self::TYPE_ID && $this->mAuto ){
 1008+ $type = self::TYPE_AUTO;
 1009+ }
 1010+
 1011+ return array( $target, $type );
9981012 }
9991013 }
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -3021,6 +3021,7 @@
30223022 'whatlinkshere-filters' => 'Filters',
30233023
30243024 # Block/unblock
 3025+'autoblockid' => 'Autoblock #$1',
30253026 'blockip' => 'Block user',
30263027 'blockip-title' => 'Block user',
30273028 'blockip-legend' => 'Block user',

Follow-up revisions

RevisionCommit summaryAuthorDate
r83829Follow-up r83827: a Block object will never be internally of TYPE_ID.happy-melon15:44, 13 March 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r83825Some refactoring in Block.php and SpecialBlock.php: move backend stuff into B...happy-melon14:47, 13 March 2011

Status & tagging log