Fix max(-1) is smaller than min(0) warning

Warning:  mt_rand() [<a href='function.mt-rand'>function.mt-rand</a>]: max(-1) is smaller than min(0) in /usr/local/apache/common-local/php-1.20wmf10/extensions/ConfirmEdit/FancyCaptcha.class.php on
line 135

Change-Id: I344504c133c84aea24ce38a4a4c05c2a0c12041b
This commit is contained in:
Reedy 2012-08-30 16:49:16 +01:00 committed by Gerrit Code Review
parent 3ef1ab740a
commit 881ab04b19

View file

@ -132,7 +132,11 @@ class FancyCaptcha extends SimpleCaptcha {
if ( !is_dir( $directory ) ) {
return false;
}
$n = mt_rand( 0, $this->countFiles( $directory ) - 1 );
$dirCount = $this->countFiles( $directory );
if ( $dirCount === 0 ) {
return false;
}
$n = mt_rand( 0, $dirCount - 1 );
$dir = opendir( $directory );
$count = 0;