* Fixed E_NOTICE..
[mediawiki.git] / includes / SpecialRandomredirect.php
blobb7aa3e490b56842a6601aae5f83b53d1c390cdf0
1 <?php
3 /**
4 * Special page to direct the user to a random redirect page (minus the second redirect)
6 * @addtogroup SpecialPage
7 * @author Rob Church <robchur@gmail.com>, Ilmari Karonen
8 * @license GNU General Public Licence 2.0 or later
9 */
11 /**
12 * Main execution point
13 * @param $par Namespace to select the redirect from
15 function wfSpecialRandomredirect( $par = null ) {
16 global $wgOut, $wgContLang;
18 $rnd = new RandomPage();
19 $rnd->setNamespace( $wgContLang->getNsIndex( $par ) );
20 $rnd->setRedirect( true );
22 $title = $rnd->getRandomTitle();
24 if( is_null( $title ) ) {
25 $wgOut->addWikiText( wfMsg( 'randomredirect-nopages' ) );
26 return;
29 $wgOut->reportTime();
30 $wgOut->redirect( $title->getFullUrl( 'redirect=no' ) );