r37717 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37716‎ | r37717 | r37718 >
Date:21:29, 15 July 2008
Author:catrope
Status:old
Tags:
Comment:
Revert r37712 which was itself a revert of r37642 (filter by protocol in list-all-links mode). $protocol is validated already: only protocols in $wgUrlProtocols are accepted (line 168) and the : (and, if required, //) part is added in lines 57-65, making both reasons for the revert moot.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryExtLinksUsage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryExtLinksUsage.php
@@ -54,7 +54,7 @@
5555
5656 // Find the right prefix
5757 global $wgUrlProtocols;
58 - if(!is_null($protocol) && $protocol != '' && !in_array($protocol, $wgUrlProtocols))
 58+ if(!is_null($protocol) && !empty($protocol) && !in_array($protocol, $wgUrlProtocols))
5959 {
6060 foreach ($wgUrlProtocols as $p) {
6161 if( substr( $p, 0, strlen( $protocol ) ) === $protocol ) {
@@ -63,6 +63,8 @@
6464 }
6565 }
6666 }
 67+ else
 68+ $protocol = null;
6769
6870 $db = $this->getDb();
6971 $this->addTables(array('page','externallinks')); // must be in this order for 'USE INDEX'
@@ -72,12 +74,17 @@
7375
7476 if(!is_null($query) || $query != '')
7577 {
76 - $likeQuery = LinkFilter::makeLike($query , $protocol);
 78+ if(is_null($protocol))
 79+ $protocol = 'http';
 80+
 81+ $likeQuery = LinkFilter::makeLike($query, $protocol);
7782 if (!$likeQuery)
7883 $this->dieUsage('Invalid query', 'bad_query');
7984 $likeQuery = substr($likeQuery, 0, strpos($likeQuery,'%')+1);
8085 $this->addWhere('el_index LIKE ' . $db->addQuotes( $likeQuery ));
8186 }
 87+ else if(!is_null($protocol))
 88+ $this->addWhere('el_index LIKE ' . $db->addQuotes( "$protocol%" ));
8289
8390 $prop = array_flip($params['prop']);
8491 $fld_ids = isset($prop['ids']);
@@ -139,7 +146,7 @@
140147
141148 public function getAllowedParams() {
142149 global $wgUrlProtocols;
143 - $protocols = array();
 150+ $protocols = array('');
144151 foreach ($wgUrlProtocols as $p) {
145152 $protocols[] = substr($p, 0, strpos($p,':'));
146153 }
@@ -159,7 +166,7 @@
160167 ),
161168 'protocol' => array (
162169 ApiBase :: PARAM_TYPE => $protocols,
163 - ApiBase :: PARAM_DFLT => 'http',
 170+ ApiBase :: PARAM_DFLT => '',
164171 ),
165172 'query' => null,
166173 'namespace' => array (
@@ -180,8 +187,9 @@
181188 return array (
182189 'prop' => 'What pieces of information to include',
183190 'offset' => 'Used for paging. Use the value returned for "continue"',
184 - 'protocol' => 'Protocol of the url',
185 - 'query' => 'Search string without protocol. See [[Special:LinkSearch]]. Leave empty to list all external links (euprotocol will be ignored)',
 191+ 'protocol' => array( 'Protocol of the url. If empty and euquery set, the protocol is http.',
 192+ 'Leave both this and euquery empty to list all external links'),
 193+ 'query' => 'Search string without protocol. See [[Special:LinkSearch]]. Leave empty to list all external links',
186194 'namespace' => 'The page namespace(s) to enumerate.',
187195 'limit' => 'How many entries to return.'
188196 );
Index: trunk/phase3/RELEASE-NOTES
@@ -536,6 +536,7 @@
537537 prop={links,templatelinks,langlinks,extlinks,categories,images}
538538 * Added flag "top" to list=usercontribs if the user is the last contributor to
539539 the page
 540+* list=exturlusage in "list all links" mode can now filter by protocol
540541
541542 === Languages updated in 1.13 ===
542543

Follow-up revisions

RevisionCommit summaryAuthorDate
r37723Revert r37717 -- if you didn't like the other reasons, the fact that it obvio...brion21:53, 15 July 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r37642API list=exturlusage: Added possibility to filter by protocol in "list all li...catrope12:04, 14 July 2008
r37712Revert r37642 for now ('Added possibility to filter by protocol in "list all ...brion20:51, 15 July 2008

Status & tagging log