r84335 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84334‎ | r84335 | r84336 >
Date:16:50, 19 March 2011
Author:happy-melon
Status:ok
Tags:
Comment:
Clarify the behaviour of Block::parseTarget(), and that TYPE_AUTO and TYPE_ID are broadly the same.
Modified paths:
  • /trunk/phase3/includes/Block.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Block.php
@@ -933,6 +933,9 @@
934934
935935 $userObj = User::newFromName( $target );
936936 if( $userObj instanceof User ){
 937+ # Note that since numbers are valid usernames, a $target of "12345" will be
 938+ # considered a User. If you want to pass a block ID, prepend a hash "#12345",
 939+ # since hash characters are not valid in usernames or titles generally.
937940 return array( $userObj, Block::TYPE_USER );
938941
939942 } elseif( IP::isValid( $target ) ){
@@ -951,9 +954,9 @@
952955 # Autoblock reference in the form "#12345"
953956 return array( substr( $target, 1 ), Block::TYPE_AUTO );
954957
955 - } elseif( preg_match( '/^\d+$/', $target ) ){
956 - # Block id reference as a pure number
957 - return array( $target, Block::TYPE_ID );
 958+ } else {
 959+ # WTF?
 960+ return array( null, null );
958961 }
959962 }
960963

Status & tagging log