[Mediawiki-l] Randompage bug

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


Hello,

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

The algorithm picks a random number, then checks in the database for a page
with a higher cur_random (a random value given to each page), and takes the
first page that matches. The problem with this is I only have 2 pages, both
with a very low cur_random value. So often I get redirected to an empty page
(404). I don't know if there's a way to fix this, or a workaround (other
than "make more pages")? Maybe, instead of doing '$rt = "" ' in the else,
you could do another query, but this time with "AND cur_random < $randstr
AND cur_random > 0" (to avoid the homepage).

Final code: (in includes/SpecialRandompage.php)
...
 } else {
  $sqlget = "SELECT cur_id,cur_title
   FROM cur USE INDEX (cur_random)
   WHERE cur_namespace=0 AND cur_is_redirect=0
   AND cur_random<$randstr
   AND cur_random > 0
   ORDER BY cur_random DESC
   LIMIT 1";
  $res = wfQuery( $sqlget, DB_READ, $fname );
  if( $s = wfFetchObject( $res ) ) {
   $rt = wfUrlEncode( $s->cur_title );
  } else {
   # No articles?!
   $rt = "";
  }
 }
...

This solution isn't good, it takes nearly always the same page. There should
be a better way :-)


And I also have a problem when I edit a page, then press Save. I get told
there was a conflicting error, but when I return to the page, the update has
been done. I think it's some problem with my session-things (I'm using a
windows webserver, not apache).

Any comments?
    Tom





More information about the MediaWiki-l mailing list