4 * @subpackage SpecialPage
10 function wfSpecialRandomFA() {
11 global $wgOut, $wgTitle, $wgArticle, $wgContLang;
12 $fname = 'wfSpecialRandomFA';
14 $dbr =& wfGetDB( DB_SLAVE
);
15 $use_index = $dbr->useIndexClause( 'page_random' );
16 extract( $dbr->tableNames( 'page', 'pagelinks' ) );
18 $randstr = wfRandom();
19 $ft = Title
::newFromText( wfMsgForContent( 'featuredtemplate' ) );
20 if ( is_null( $ft ) ) {
21 $title = Title
::newFromText( wfMsgForContent( 'mainpage' ) );
22 $wgOut->redirect( $title->getFullUrl() );
25 $template = $dbr->addQuotes( $ft->getDBkey() );
27 SELECT page_title, page_random
29 LEFT JOIN $page $use_index ON page_id = pl_from
30 WHERE pl_title = $template AND pl_namespace = " . NS_TEMPLATE
. " AND page_namespace = " . NS_TALK
. " AND page_random > $randstr
33 $sql = $dbr->limitResult($sql, 1, 0);
34 $res = $dbr->query( $sql, $fname );
37 if ( $s = $dbr->fetchObject( $res ) ) {
38 $title =& Title
::makeTitle( NS_MAIN
, $s->page_title
);
40 if ( is_null( $title ) ) {
41 # That's not supposed to happen :)
42 $title = Title
::newFromText( wfMsgForContent( 'mainpage' ) );
44 $wgOut->reportTime(); # for logfile
45 $wgOut->redirect( $title->getFullUrl() );