From 04e5a7daa3eb1e4ae3e42f5b69099dbdaba9327b Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Sat, 19 Mar 2011 16:50:21 +0000 Subject: [PATCH] Clarify the behaviour of Block::parseTarget(), and that TYPE_AUTO and TYPE_ID are broadly the same. --- includes/Block.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 ); } } -- 2.20.1