From b9b85843572bf283f48285001e276ba7e61b63f6 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 22 Feb 2009 13:37:51 +0100 Subject: updated to MediaWiki 1.14.0 --- includes/api/ApiQueryRandom.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'includes/api/ApiQueryRandom.php') diff --git a/includes/api/ApiQueryRandom.php b/includes/api/ApiQueryRandom.php index 046157a6..e7b8bf46 100644 --- a/includes/api/ApiQueryRandom.php +++ b/includes/api/ApiQueryRandom.php @@ -48,13 +48,13 @@ if (!defined('MEDIAWIKI')) { $this->run($resultPageSet); } - protected function prepareQuery($randstr, $limit, $namespace, &$resultPageSet) { + protected function prepareQuery($randstr, $limit, $namespace, &$resultPageSet, $redirect) { $this->resetQueryParams(); $this->addTables('page'); $this->addOption('LIMIT', $limit); $this->addWhereFld('page_namespace', $namespace); $this->addWhereRange('page_random', 'newer', $randstr, null); - $this->addWhere(array('page_is_redirect' => 0)); + $this->addWhereFld('page_is_redirect', $redirect); $this->addOption('USE INDEX', 'page_random'); if(is_null($resultPageSet)) $this->addFields(array('page_id', 'page_title', 'page_namespace')); @@ -89,7 +89,8 @@ if (!defined('MEDIAWIKI')) { $result = $this->getResult(); $data = array(); $this->pageIDs = array(); - $this->prepareQuery(wfRandom(), $params['limit'], $params['namespace'], $resultPageSet); + + $this->prepareQuery(wfRandom(), $params['limit'], $params['namespace'], $resultPageSet, $params['redirect']); $count = $this->runQuery($data, $resultPageSet); if($count < $params['limit']) { @@ -97,7 +98,7 @@ if (!defined('MEDIAWIKI')) { * for page_random. We'll just take the lowest ones, see * also the comment in Title::getRandomTitle() */ - $this->prepareQuery(0, $params['limit'] - $count, $params['namespace'], $resultPageSet); + $this->prepareQuery(0, $params['limit'] - $count, $params['namespace'], $resultPageSet, $params['redirect']); $this->runQuery($data, $resultPageSet); } @@ -129,13 +130,15 @@ if (!defined('MEDIAWIKI')) { ApiBase :: PARAM_MAX => 10, ApiBase :: PARAM_MAX2 => 20 ), + 'redirect' => false, ); } public function getParamDescription() { return array ( 'namespace' => 'Return pages in these namespaces only', - 'limit' => 'Limit how many random pages will be returned' + 'limit' => 'Limit how many random pages will be returned', + 'redirect' => 'Load a random redirect instead of a random page' ); } -- cgit v1.2.3-54-g00ecf