From: Kaldari Date: Thu, 13 Aug 2015 02:27:20 +0000 (-0700) Subject: Adding a new hook to allow modification of Special:Random query X-Git-Tag: 1.31.0-rc.0~10441 X-Git-Url: http://git.cyclocoop.org//%22%22.str_replace%28%27%22%27%2C?a=commitdiff_plain;h=b74b3f04b3a8cbb170a8c69a2ff65c29073313d4;p=lhc%2Fweb%2Fwiklou.git Adding a new hook to allow modification of Special:Random query See: Ia84c54dcdadf54e9475c1dc7d0ec7c2c48afeaae Bug: T9937 Change-Id: I91cd231d1cbf610f20134fd0271af46842a9a17d --- diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26 index 986ebc3f44..383c6822e2 100644 --- a/RELEASE-NOTES-1.26 +++ b/RELEASE-NOTES-1.26 @@ -55,6 +55,8 @@ production. the store type from $wgObjectCaches. The default is the local database. * Interface message overrides in the MediaWiki namespace will now be cached in memcached and APC (if available), rather than memcached and local files. +* Added a new hook, 'RandomPageQuery', to allow modification of the query used + by Special:Random to select random pages. * $wgTransactionalTimeLimit was added, which controls the request time limit for potentially slow POST requests that need to be as atomic as possible. diff --git a/includes/specials/SpecialRandompage.php b/includes/specials/SpecialRandompage.php index 73a88b9edc..9f7ef6690e 100644 --- a/includes/specials/SpecialRandompage.php +++ b/includes/specials/SpecialRandompage.php @@ -135,20 +135,26 @@ class RandomPage extends SpecialPage { protected function getQueryInfo( $randstr ) { $redirect = $this->isRedirect() ? 1 : 0; + $tables = array( 'page' ); + $conds = array_merge( array( + 'page_namespace' => $this->namespaces, + 'page_is_redirect' => $redirect, + 'page_random >= ' . $randstr + ), $this->extra ); + $joinConds = array(); + + // Allow extensions to modify the query + Hooks::run( 'RandomPageQuery', array( &$tables, &$conds, &$joinConds ) ); return array( - 'tables' => array( 'page' ), + 'tables' => $tables, 'fields' => array( 'page_title', 'page_namespace' ), - 'conds' => array_merge( array( - 'page_namespace' => $this->namespaces, - 'page_is_redirect' => $redirect, - 'page_random >= ' . $randstr - ), $this->extra ), + 'conds' => $conds, 'options' => array( 'ORDER BY' => 'page_random', 'LIMIT' => 1, ), - 'join_conds' => array() + 'join_conds' => $joinConds ); }