aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiQueryWatchlist.php
diff options
context:
space:
mode:
authorYuri Astrakhan <yurik@users.mediawiki.org>2006-10-14 16:02:42 +0000
committerYuri Astrakhan <yurik@users.mediawiki.org>2006-10-14 16:02:42 +0000
commit9262f69c0a234f6a55a5802be57e7bf5997f6509 (patch)
tree123c42bbec47220dcd955ffae7fa70d0468c0735 /includes/api/ApiQueryWatchlist.php
parente13d9f078dec14c743c798b7fffd831bd8258639 (diff)
downloadmediawikicore-9262f69c0a234f6a55a5802be57e7bf5997f6509.tar.gz
mediawikicore-9262f69c0a234f6a55a5802be57e7bf5997f6509.zip
* API watchlist: Forced an index, enabled generator
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/17013
Diffstat (limited to 'includes/api/ApiQueryWatchlist.php')
-rw-r--r--includes/api/ApiQueryWatchlist.php93
1 files changed, 54 insertions, 39 deletions
diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php
index 9170e7f6b519..0033d5c56d6a 100644
--- a/includes/api/ApiQueryWatchlist.php
+++ b/includes/api/ApiQueryWatchlist.php
@@ -54,30 +54,52 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
$db = $this->getDB();
+ $dirNewer = ($dir === 'newer');
+ $before = ($dirNewer ? '<=' : '>=');
+ $after = ($dirNewer ? '>=' : '<=');
+
$tables = array (
'watchlist',
- 'recentchanges',
- 'page'
- );
- $fields = array (
- 'rc_namespace AS page_namespace',
- 'rc_title AS page_title',
- 'rc_comment AS rev_comment',
- 'rc_cur_id AS page_id',
- 'rc_user AS rev_user',
- 'rc_user_text AS rev_user_text',
- 'rc_timestamp AS rev_timestamp',
- 'rc_minor AS rev_minor_edit',
- 'rc_this_oldid AS rev_id',
- 'rc_last_oldid',
- 'rc_id',
-// 'rc_patrolled',
- 'rc_new AS page_is_new'
+ 'page',
+ 'recentchanges'
);
- $dirNewer = ($dir === 'newer');
- $before = ($dirNewer ? '<=' : '>=');
- $after = ($dirNewer ? '>=' : '<=');
+ $options = array (
+ 'LIMIT' => $limit +1,
+ 'ORDER BY' => 'rc_timestamp' . ($dirNewer ? '' : ' DESC'),
+ 'USE INDEX' => 'rc_timestamp');
+
+ if (is_null($resultPageSet)) {
+ $fields = array (
+ 'rc_namespace AS page_namespace',
+ 'rc_title AS page_title',
+ 'rc_comment AS rev_comment',
+ 'rc_cur_id AS page_id',
+ 'rc_user AS rev_user',
+ 'rc_user_text AS rev_user_text',
+ 'rc_timestamp AS rev_timestamp',
+ 'rc_minor AS rev_minor_edit',
+ 'rc_this_oldid AS rev_id',
+ 'rc_last_oldid',
+ 'rc_id',
+ // 'rc_patrolled',
+ 'rc_new AS page_is_new'
+ );
+ } elseif ($allrev) {
+ $fields = array (
+ 'rc_this_oldid AS rev_id',
+ 'rc_namespace AS page_namespace',
+ 'rc_title AS page_title',
+ 'rc_timestamp AS rev_timestamp'
+ );
+ } else {
+ $fields = array (
+ 'rc_cur_id AS page_id',
+ 'rc_namespace AS page_namespace',
+ 'rc_title AS page_title',
+ 'rc_timestamp AS rev_timestamp'
+ );
+ }
$where = array (
'wl_namespace = rc_namespace',
@@ -94,21 +116,6 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
if (isset ($end))
$where[] = 'rev_timestamp' . $before . $db->addQuotes($end);
- // if (is_null($resultPageSet)) {
- // $fields = array (
- // 'page_id',
- // 'page_namespace',
- // 'page_title'
- // );
- // } else {
- // $fields = $resultPageSet->getPageTableFields();
- // }
-
- $options = array (
- 'LIMIT' => $limit +1,
- 'ORDER BY' => 'rc_timestamp' . ($dirNewer ? '' : ' DESC'
- ));
-
$this->profileDBIn();
$res = $db->select($tables, $fields, $where, __METHOD__, $options);
$this->profileDBOut();
@@ -147,9 +154,11 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
// 'rc_patrolled' => $row->rc_patrolled,
'isnew' => $row->page_is_new
);
+ } elseif ($allrev) {
+ $data[] = intval($row->rev_id);
} else {
-// $resultPageSet->processDbRow($row);
- }
+ $data[] = intval($row->page_id);
+ }
}
}
$db->freeResult($res);
@@ -157,7 +166,11 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
if (is_null($resultPageSet)) {
ApiResult :: setIndexedTagName($data, 'p');
$this->getResult()->addValue('query', 'watchlist', $data);
- }
+ } elseif ($allrev) {
+ $resultPageSet->populateFromRevisionIDs($data);
+ } else {
+ $resultPageSet->populateFromPageIDs($data);
+ }
}
protected function getAllowedParams() {
@@ -209,7 +222,9 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
protected function getExamples() {
return array (
'api.php?action=query&list=watchlist',
- 'api.php?action=query&list=watchlist&wlallrev'
+ 'api.php?action=query&list=watchlist&wlallrev',
+ 'api.php?action=query&generator=watchlist&prop=info',
+ 'api.php?action=query&generator=watchlist&gwlallrev&prop=revisions&rvprop=timestamp|user'
);
}