r37725 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37724‎ | r37725 | r37726 >
Date:22:03, 15 July 2008
Author:catrope
Status:old
Tags:
Comment:
Redoing r37642 ('Added possibility to filter by protocol in "list all links" mode') *really* right this time, the example broke because I had 'http' instead of 'http://' on line 78.
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
@@ -529,6 +529,7 @@
530530 prop={links,templatelinks,langlinks,extlinks,categories,images}
531531 * Added flag "top" to list=usercontribs if the user is the last contributor to
532532 the page
 533+* list=exturlusage in "list all links" mode can now filter by protocol
533534
534535 === Languages updated in 1.13 ===
535536

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