51 $services = MediaWikiServices::getInstance();
54 : $services->getDBLoadBalancer();
55 $nsInfo = $nsInfo ?? $services->getNamespaceInfo();
56 $this->namespaces = $nsInfo->getContentNamespaces();
67 $this->namespaces = [ $ns ];
76 if ( is_string( $par ) ) {
88 $this->
getNsList(), count( $this->namespaces ) );
93 $redirectParam = $this->
isRedirect() ? [
'redirect' =>
'no' ] : [];
94 $query = array_merge( $this->
getRequest()->getValues(), $redirectParam );
95 unset( $query[
'title'] );
107 foreach ( $this->namespaces as $n ) {
109 $nsNames[] = $this->
msg(
'blanknamespace' )->plain();
111 $nsNames[] = $contLang->getNsText( $n );
115 return $contLang->commaList( $nsNames );
127 $randstr, $this->isRedir, $this->namespaces,
156 $tables = [
'page' ];
157 $conds = array_merge( [
158 'page_namespace' => $this->namespaces,
159 'page_is_redirect' => $redirect,
160 'page_random >= ' . $randstr
165 $this->
getHookRunner()->onRandomPageQuery( $tables, $conds, $joinConds );
169 'fields' => [
'page_title',
'page_namespace' ],
172 'ORDER BY' =>
'page_random',
175 'join_conds' => $joinConds
192 return $res->fetchObject();
204 class_alias( SpecialRandomPage::class,
'RandomPage' );
wfRandom()
Get a random decimal value in the domain of [0, 1), in a way not likely to give duplicate values for ...
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Parent class for all special pages.
getName()
Get the name of this Special Page.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getRequest()
Get the WebRequest being used for this instance.
getContentLanguage()
Shortcut to get content language.
Special page to direct the user to a random page.
ILoadBalancer $loadBalancer
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
execute( $par)
Default execute method Checks user permissions.
selectRandomPageFromDB( $randstr, $fname=__METHOD__)
getNsList()
Get a comma-delimited list of namespaces we don't have any pages in.
getRandomTitle()
Choose a random title.
__construct( $loadBalancer=null, NamespaceInfo $nsInfo=null)
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.