[Mediawiki-l] Randompage bug

Tom Muylle Tom.Muylle at student.kuleuven.ac.be
Sat Jun 26 02:53:13 UTC 2004


> Hello,
>
> I found a bug in the special:Randompage, it goes like this:

blablah :-)

Sorry to bother you again, I searched google for "mysql random row", guess
what..

Code: (Still in includes/SpecialRandompage.php)

function wfSpecialRandompage()
{
 global $wgOut, $wgTitle, $wgArticle, $force;
 $fname = "wfSpecialRandompage";

 wfSeedRandom();
$result=wfQuery("SELECT cur_title FROM cur WHERE cur_namespace = 0 and
cur_is_redirect=0 and cur_random > 0", DB_READ, $fname);
$min=1;
$max=wfNumRows($result);
if ($max > 0) {
    wfDataSeek($result,rand($min,$max)-1);
    if ($row = wfFetchObject($result)) {
     $rt = wfUrlEncode($row -> cur_title);
    }
    else {
     $rt = "";
    }
}
else {
 $rt = "";
}
 $wgOut->reportTime(); # for logfile
 $wgOut->redirect( wfLocalUrl( $rt ) );
}


As you can see, it takes a random tuple from the ones returned by the query.

Thanks for reading all this,
    Tom





More information about the MediaWiki-l mailing list