X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fhtmlform%2Ffields%2FHTMLUserTextField.php;h=5b3bc25ef8ca0f55a3d62e4f40aa4d3a4e6be282;hb=94022121b5415796e4ee0c89d41ddcd73c3fd3da;hp=e1939705abf16fa965381e21871fc7eccaecdc16;hpb=c9a71813b828b22c3ea58c16731449dca3eacd53;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/htmlform/fields/HTMLUserTextField.php b/includes/htmlform/fields/HTMLUserTextField.php index e1939705ab..5b3bc25ef8 100644 --- a/includes/htmlform/fields/HTMLUserTextField.php +++ b/includes/htmlform/fields/HTMLUserTextField.php @@ -34,6 +34,11 @@ class HTMLUserTextField extends HTMLTextField { } public function validate( $value, $alldata ) { + // Default value (from getDefault()) is null, User::newFromName() expects a string + if ( $value === null ) { + $value = ''; + } + // check, if a user exists with the given username $user = User::newFromName( $value, false ); $rangeError = null; @@ -43,7 +48,7 @@ class HTMLUserTextField extends HTMLTextField { } elseif ( // check, if the user exists, if requested ( $this->mParams['exists'] && $user->getId() === 0 ) && - // check, if the username is a valid IP address, otherweise save the error message + // check, if the username is a valid IP address, otherwise save the error message !( $this->mParams['ipallowed'] && IP::isValid( $value ) ) && // check, if the username is a valid IP range, otherwise save the error message !( $this->mParams['iprange'] && ( $rangeError = $this->isValidIPRange( $value ) ) === true ) @@ -60,7 +65,7 @@ class HTMLUserTextField extends HTMLTextField { protected function isValidIPRange( $value ) { $cidrIPRanges = $this->mParams['iprangelimits']; - if ( !IP::isValidBlock( $value ) ) { + if ( !IP::isValidRange( $value ) ) { return false; }