yurik@svn.wikimedia.org wrote:
if ($wgUser->isBlocked()) {
$id = $wgUser->blockedBy();
$vals['blockedby'] = is_numeric($id) ? User::whoIs($id) : $id;
This seems a little weird here... From what I can see, User::blockedBy() should always return a user ID, never a name, so the is_numeric() check shouldn't be needed here.
Secondly, the check would get false results if it did return a name sometimes -- legitimate usernames might match is_numeric(), and you'd then load a different, wrong username.
-- brion vibber (brion @ wikimedia.org)
Brion, the code was copied from the OutputPage.php line 751: if ( is_numeric( $id ) ) { $name = User::whoIs( $id ); } else { $name = $id; }
Guess it should be fixed there as well.
--Yuri
On 8/1/07, Brion Vibber brion@wikimedia.org wrote:
yurik@svn.wikimedia.org wrote:
if ($wgUser->isBlocked()) {
$id = $wgUser->blockedBy();
$vals['blockedby'] = is_numeric($id) ? User::whoIs($id) : $id;
This seems a little weird here... From what I can see, User::blockedBy() should always return a user ID, never a name, so the is_numeric() check shouldn't be needed here.
Secondly, the check would get false results if it did return a name sometimes -- legitimate usernames might match is_numeric(), and you'd then load a different, wrong username.
-- brion vibber (brion @ wikimedia.org)
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org http://lists.wikimedia.org/mailman/listinfo/wikitech-l
Yuri Astrakhan wrote:
Brion, the code was copied from the OutputPage.php line 751: if ( is_numeric( $id ) ) { $name = User::whoIs( $id ); } else { $name = $id; }
Guess it should be fixed there as well.
Probably, yes.
Note that almost *every* time you see is_numeric() it's probably wrong. Usually people seem to use it when what they *mean* is preg_match('/^\d+$/'), but it also matches things with decimals, hex, etc.
return is_numeric('234.444');
bool(true)
return is_numeric(' 234');
bool(true)
return is_numeric('0x7f');
bool(true)
-- brion vibber (brion @ wikimedia.org)
wikitech-l@lists.wikimedia.org