<?php
/**
- * @version # $Id$
* @package MediaWiki
* @subpackage SpecialPage
*/
#
# 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' );
- $cur = $db->tableName( 'cur' );
+ $use_index = $db->useIndexClause( 'page_random' );
+ $page = $db->tableName( 'page' );
if ( $wgExtraRandompageSQL ) {
$extra = "AND ($wgExtraRandompageSQL)";
} else {
$extra = '';
}
- $sqlget = "SELECT cur_id,cur_title
- FROM $cur $use_index
- WHERE cur_namespace=0 AND cur_is_redirect=0 $extra
- AND cur_random>$randstr
- ORDER BY cur_random
+ $sqlget = "SELECT page_id,page_title
+ FROM $page $use_index
+ WHERE page_namespace=".NS_MAIN." AND page_is_redirect=0 $extra
+ AND page_random>$randstr
+ ORDER BY page_random
LIMIT 1";
$res = $db->query( $sqlget, $fname );
$title = null;
if( $s = $db->fetchObject( $res ) ) {
- $title =& Title::makeTitle( NS_MAIN, $s->cur_title );
+ $title =& Title::makeTitle( NS_MAIN, $s->page_title );
}
if( is_null( $title ) ) {
# That's not supposed to happen :)