}
}
+/**
+ * Get a random decimal value between 0 and 1, in a way
+ * not likely to give duplicate values for any realistic
+ * number of articles.
+ *
+ * @return string
+ */
+function wfRandom() {
+ # The maximum random value is "only" 2^31-1, so get two random
+ # values to reduce the chance of dupes
+ $max = mt_getrandmax();
+ $rand = number_format( mt_rand() * mt_rand()
+ / $max / $max, 12, '.', '' );
+ return $rand;
+}
+
/**
* We want / and : to be included as literal characters in our title URLs.
* %2F in the page titles seems to fatally break for some reason.
#
# Using a literal constant means the whole thing gets optimized on
# the index, and the comparison is both fast and fair.
- $rand = mt_rand() / mt_getrandmax();
# interpolation and sprintf() can muck up with locale-specific decimal separator
- $randstr = number_format( $rand, 12, ".", "" );
+ $randstr = wfRandom();
$db =& wfGetDB( DB_SLAVE );
$use_index = $db->useIndexClause( 'cur_random' );
$redirect = MagicWord::get( MAG_REDIRECT );
$redir = $redirect->matchStart( $text ) ? 1 : 0;
- $rand = number_format( mt_rand() / mt_getrandmax(), 12, '.', '' );
+ $rand = wfRandom();
$dbw->insertArray( 'cur', array(
'cur_id' => $dbw->nextSequenceValue( 'cur_cur_id_seq' ),
'cur_namespace' => $namespace,
$now = $dbw->timestamp();
$won = wfInvertTimestamp( wfTimestamp(TS_MW,$now) );
wfSeedRandom();
- $rand = number_format( mt_rand() / mt_getrandmax(), 12, '.', '' );
+ $rand = wfRandom();
# Rename cur entry
$dbw->updateArray( 'cur',