r24694 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24693‎ | r24694 | r24695 >
Date:08:41, 9 August 2007
Author:yurik
Status:old
Tags:
Comment:
API:
* Added rvprop=size to prop=revisions. Can get the size of all the revisions. The size will not be shown if it is NULL in the database.
* (Experimental) list=allpages now allows to filter by article min/max size and protection status (thanks to [[en:user:madman]] for the idea). The database performance of this addition might be so severe that I might have to remove or restrict it.
Breaking change:
* list=exturlusage XML element's tag is now 'eu' instead of 'p' to be more consistent with the other results.
Modified paths:
  • /trunk/phase3/includes/api/ApiQueryAllpages.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryExtLinksUsage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryExtLinksUsage.php
@@ -129,7 +129,7 @@
130130
131131 if (is_null($resultPageSet)) {
132132 $result = $this->getResult();
133 - $result->setIndexedTagName($data, 'p');
 133+ $result->setIndexedTagName($data, $this->getModulePrefix());
134134 $result->addValue('query', $this->getModuleName(), $data);
135135 }
136136 }
Index: trunk/phase3/includes/api/ApiQueryAllpages.php
@@ -55,8 +55,8 @@
5656 $db = $this->getDB();
5757
5858 $params = $this->extractRequestParams();
59 -
60 - $this->addTables('page');
 59+
 60+ // Page filters
6161 if (!$this->addWhereIf('page_is_redirect = 1', $params['filterredir'] === 'redirects'))
6262 $this->addWhereIf('page_is_redirect = 0', $params['filterredir'] === 'nonredirects');
6363 $this->addWhereFld('page_namespace', $params['namespace']);
@@ -65,6 +65,39 @@
6666 if (isset ($params['prefix']))
6767 $this->addWhere("page_title LIKE '" . $db->escapeLike(ApiQueryBase :: titleToKey($params['prefix'])) . "%'");
6868
 69+ $forceNameTitleIndex = true;
 70+ if (isset ($params['minsize'])) {
 71+ $this->addWhere('page_len>=' . intval($params['minsize']));
 72+ $forceNameTitleIndex = false;
 73+ }
 74+
 75+ if (isset ($params['maxsize'])) {
 76+ $this->addWhere('page_len<=' . intval($params['maxsize']));
 77+ $forceNameTitleIndex = false;
 78+ }
 79+
 80+ // Page protection filtering
 81+ if (isset ($params['prtype'])) {
 82+ $this->addTables('page_restrictions');
 83+ $this->addWhere('page_id=pr_page');
 84+ $this->addWhere('pr_expiry>' . $db->addQuotes($db->timestamp()));
 85+ $this->addWhereFld('pr_type', $params['prtype']);
 86+
 87+ $prlevel = $params['prlevel'];
 88+ if (!is_null($prlevel) && $prlevel != '' && $prlevel != '*')
 89+ $this->addWhereFld('pr_level', $prlevel);
 90+
 91+ $forceNameTitleIndex = false;
 92+
 93+ } else if (isset ($params['prlevel'])) {
 94+ $this->dieUsage('prlevel may not be used without prtype', 'params');
 95+ }
 96+
 97+ $this->addTables('page');
 98+ if ($forceNameTitleIndex)
 99+ $this->addOption('USE INDEX', 'name_title');
 100+
 101+
69102 if (is_null($resultPageSet)) {
70103 $this->addFields(array (
71104 'page_id',
@@ -75,7 +108,6 @@
76109 $this->addFields($resultPageSet->getPageTableFields());
77110 }
78111
79 - $this->addOption('USE INDEX', 'name_title');
80112 $limit = $params['limit'];
81113 $this->addOption('LIMIT', $limit+1);
82114 $this->addOption('ORDER BY', 'page_namespace, page_title');
@@ -112,12 +144,14 @@
113145 }
114146
115147 protected function getAllowedParams() {
 148+ global $wgRestrictionTypes, $wgRestrictionLevels;
 149+
116150 return array (
117151 'from' => null,
118152 'prefix' => null,
119153 'namespace' => array (
120154 ApiBase :: PARAM_DFLT => 0,
121 - ApiBase :: PARAM_TYPE => 'namespace'
 155+ ApiBase :: PARAM_TYPE => 'namespace',
122156 ),
123157 'filterredir' => array (
124158 ApiBase :: PARAM_DFLT => 'all',
@@ -127,6 +161,18 @@
128162 'nonredirects'
129163 )
130164 ),
 165+ 'minsize' => array (
 166+ ApiBase :: PARAM_TYPE => 'integer',
 167+ ),
 168+ 'maxsize' => array (
 169+ ApiBase :: PARAM_TYPE => 'integer',
 170+ ),
 171+ 'prtype' => array (
 172+ ApiBase :: PARAM_TYPE => $wgRestrictionTypes,
 173+ ),
 174+ 'prlevel' => array (
 175+ ApiBase :: PARAM_TYPE => $wgRestrictionLevels,
 176+ ),
131177 'limit' => array (
132178 ApiBase :: PARAM_DFLT => 10,
133179 ApiBase :: PARAM_TYPE => 'limit',
@@ -143,6 +189,10 @@
144190 'prefix' => 'Search for all page titles that begin with this value.',
145191 'namespace' => 'The namespace to enumerate.',
146192 'filterredir' => 'Which pages to list.',
 193+ 'minsize' => 'Limit to pages with at least this many bytes',
 194+ 'maxsize' => 'Limit to pages with at most this many bytes',
 195+ 'prtype' => 'Limit to protected pages only',
 196+ 'prlevel' => 'The protection level (must be used with apprtype= parameter)',
147197 'limit' => 'How many total pages to return.'
148198 );
149199 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r24755Merged revisions 24694-24754 via svnmerge from...david19:48, 13 August 2007

Status & tagging log