r37712 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37711‎ | r37712 | r37713 >
Date:20:51, 15 July 2008
Author:brion
Status:old
Tags:
Comment:
Revert r37642 for now ('Added possibility to filter by protocol in "list all links" mode.'):
* doesn't properly validate $protocol when building like query for protocol-only case, could lead to ugly slow arbitrary queries
* no : added to protocol -- will match false positives (eg 'http' matching 'https')
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) && !empty($protocol) && !in_array($protocol, $wgUrlProtocols))
 58+ if(!is_null($protocol) && $protocol != '' && !in_array($protocol, $wgUrlProtocols))
5959 {
6060 foreach ($wgUrlProtocols as $p) {
6161 if( substr( $p, 0, strlen( $protocol ) ) === $protocol ) {
@@ -63,8 +63,6 @@
6464 }
6565 }
6666 }
67 - else
68 - $protocol = null;
6967
7068 $db = $this->getDb();
7169 $this->addTables(array('page','externallinks')); // must be in this order for 'USE INDEX'
@@ -74,17 +72,12 @@
7573
7674 if(!is_null($query) || $query != '')
7775 {
78 - if(is_null($protocol))
79 - $protocol = 'http';
80 -
81 - $likeQuery = LinkFilter::makeLike($query, $protocol);
 76+ $likeQuery = LinkFilter::makeLike($query , $protocol);
8277 if (!$likeQuery)
8378 $this->dieUsage('Invalid query', 'bad_query');
8479 $likeQuery = substr($likeQuery, 0, strpos($likeQuery,'%')+1);
8580 $this->addWhere('el_index LIKE ' . $db->addQuotes( $likeQuery ));
8681 }
87 - else if(!is_null($protocol))
88 - $this->addWhere('el_index LIKE ' . $db->addQuotes( "$protocol%" ));
8982
9083 $prop = array_flip($params['prop']);
9184 $fld_ids = isset($prop['ids']);
@@ -146,7 +139,7 @@
147140
148141 public function getAllowedParams() {
149142 global $wgUrlProtocols;
150 - $protocols = array('');
 143+ $protocols = array();
151144 foreach ($wgUrlProtocols as $p) {
152145 $protocols[] = substr($p, 0, strpos($p,':'));
153146 }
@@ -166,7 +159,7 @@
167160 ),
168161 'protocol' => array (
169162 ApiBase :: PARAM_TYPE => $protocols,
170 - ApiBase :: PARAM_DFLT => '',
 163+ ApiBase :: PARAM_DFLT => 'http',
171164 ),
172165 'query' => null,
173166 'namespace' => array (
@@ -187,9 +180,8 @@
188181 return array (
189182 'prop' => 'What pieces of information to include',
190183 'offset' => 'Used for paging. Use the value returned for "continue"',
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',
 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)',
194186 'namespace' => 'The page namespace(s) to enumerate.',
195187 'limit' => 'How many entries to return.'
196188 );
Index: trunk/phase3/RELEASE-NOTES
@@ -540,7 +540,6 @@
541541 prop={links,templatelinks,langlinks,extlinks,categories,images}
542542 * Added flag "top" to list=usercontribs if the user is the last contributor to
543543 the page
544 -* list=exturlusage in "list all links" mode can now filter by protocol
545544
546545 === Languages updated in 1.13 ===
547546

Follow-up revisions

RevisionCommit summaryAuthorDate
r37717Revert r37712 which was itself a revert of r37642 (filter by protocol in list...catrope21:29, 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

Status & tagging log