A random page can be viewed via Special:Random.
This uses the wfRandom()
function, which is capable of avoiding duplicate values for up to approximately 4,611,686,014,132,420,609 (i.e., ≈ ) articles, and the page.page_random values from the page table.
The SpecialRandomGetRandomTitle hook can be used to modify the selection criteria.
In MysqlUpdater.phpRAND() function is used to populate page_random.
, theBy default, selection will be limited to pages from namespaces in $wgContentNamespaces
. The user can choose which namespace to look in. For example, if they wanted to view a random file they could go to Special:Random/file. If they wanted to view a random mainspace page they could go to Special:Random/main, etc.
The file that implements this feature is SpecialRandomPage.php. SpecialRandomRedirect.php (Special:RandomRedirect) directs the user to a random redirect page (minus the second redirect). There is an array, $extra
, that allows for adding extra SQL statements to the query for selecting a random page from the database.
See also
- Help:Random page
- API:Random
- Special:RandomInCategory/Individual_cats
- Category:SpecialRandomGetRandomTitle extensions
- phabricator:T200703#5420648, Extension:Random In Category, SpecialRandomInCategory.php