From: Happy-melon Date: Sat, 19 Mar 2011 16:50:21 +0000 (+0000) Subject: Clarify the behaviour of Block::parseTarget(), and that TYPE_AUTO and TYPE_ID are... X-Git-Tag: 1.31.0-rc.0~31317 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=04e5a7daa3eb1e4ae3e42f5b69099dbdaba9327b;p=lhc%2Fweb%2Fwiklou.git Clarify the behaviour of Block::parseTarget(), and that TYPE_AUTO and TYPE_ID are broadly the same. --- diff --git a/includes/Block.php b/includes/Block.php index 7a84d4f2a2..9f27fef770 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -933,6 +933,9 @@ class Block { $userObj = User::newFromName( $target ); if( $userObj instanceof User ){ + # Note that since numbers are valid usernames, a $target of "12345" will be + # considered a User. If you want to pass a block ID, prepend a hash "#12345", + # since hash characters are not valid in usernames or titles generally. return array( $userObj, Block::TYPE_USER ); } elseif( IP::isValid( $target ) ){ @@ -951,9 +954,9 @@ class Block { # Autoblock reference in the form "#12345" return array( substr( $target, 1 ), Block::TYPE_AUTO ); - } elseif( preg_match( '/^\d+$/', $target ) ){ - # Block id reference as a pure number - return array( $target, Block::TYPE_ID ); + } else { + # WTF? + return array( null, null ); } }