$now = wfTimestampNow();
$won = wfInvertTimestamp( $now );
+ wfSeedRandom();
+ $rand = mt_rand() / mt_getrandmax();
$sql = "INSERT INTO cur (cur_namespace,cur_title,cur_text," .
"cur_comment,cur_user,cur_timestamp,cur_minor_edit,cur_counter," .
"cur_restrictions,cur_user_text,cur_is_redirect," .
wfStrencode( $summary ) . "', '" .
$wgUser->getID() . "', '{$now}', " .
( $isminor ? 1 : 0 ) . ", 0, '', '" .
- wfStrencode( $wgUser->getName() ) . "', $redir, 1, RAND(), '{$now}', '{$won}')";
+ wfStrencode( $wgUser->getName() ) . "', $redir, 1, $rand, '{$now}', '{$won}')";
$res = wfQuery( $sql, $fname );
$newid = wfInsertId();
$fname = "wfSpecialRandompage";
wfSeedRandom();
+ $rand = mt_rand() / mt_getrandmax();
$sqlget = "SELECT cur_id,cur_title
FROM cur USE INDEX (cur_random)
WHERE cur_namespace=0 AND cur_is_redirect=0
- AND cur_random>RAND()
+ AND cur_random>$rand
ORDER BY cur_random
LIMIT 1";
$res = wfQuery( $sqlget, $fname );
if( $s = wfFetchObject( $res ) ) {
- $sql = "UPDATE cur SET cur_random=RAND() WHERE cur_id={$s->cur_id}";
- wfQuery( $sql, $fname );
$rt = wfUrlEncode( $s->cur_title );
} else {
# No articles?!