Use Revision for individual message loads; not using it for bulk load just now; need...
[lhc/web/wiklou.git] / includes / SpecialRandompage.php
index a8c5ed3..7cd7ff0 100644 (file)
@@ -1,6 +1,5 @@
 <?php
 /**
- * @version # $Id$
  * @package MediaWiki
  * @subpackage SpecialPage
  */
@@ -20,31 +19,30 @@ function wfSpecialRandompage() {
        #
        # 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 :)