diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2009-02-22 13:37:51 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2009-02-22 13:37:51 +0100 |
commit | b9b85843572bf283f48285001e276ba7e61b63f6 (patch) | |
tree | 4c6f4571552ada9ccfb4030481dcf77308f8b254 /includes/api/ApiQueryRandom.php | |
parent | d9a20acc4e789cca747ad360d87ee3f3e7aa58c1 (diff) |
updated to MediaWiki 1.14.0
Diffstat (limited to 'includes/api/ApiQueryRandom.php')
-rw-r--r-- | includes/api/ApiQueryRandom.php | 13 |
1 files changed, 8 insertions, 5 deletions
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' ); } |