Index: trunk/phase3/includes/api/ApiQueryExtLinksUsage.php |
— | — | @@ -54,7 +54,7 @@ |
55 | 55 | |
56 | 56 | // Find the right prefix |
57 | 57 | global $wgUrlProtocols; |
58 | | - if(!is_null($protocol) && $protocol != '' && !in_array($protocol, $wgUrlProtocols)) |
| 58 | + if(!is_null($protocol) && !empty($protocol) && !in_array($protocol, $wgUrlProtocols)) |
59 | 59 | { |
60 | 60 | foreach ($wgUrlProtocols as $p) { |
61 | 61 | if( substr( $p, 0, strlen( $protocol ) ) === $protocol ) { |
— | — | @@ -63,6 +63,8 @@ |
64 | 64 | } |
65 | 65 | } |
66 | 66 | } |
| 67 | + else |
| 68 | + $protocol = null; |
67 | 69 | |
68 | 70 | $db = $this->getDb(); |
69 | 71 | $this->addTables(array('page','externallinks')); // must be in this order for 'USE INDEX' |
— | — | @@ -72,12 +74,17 @@ |
73 | 75 | |
74 | 76 | if(!is_null($query) || $query != '') |
75 | 77 | { |
76 | | - $likeQuery = LinkFilter::makeLike($query , $protocol); |
| 78 | + if(is_null($protocol)) |
| 79 | + $protocol = 'http'; |
| 80 | + |
| 81 | + $likeQuery = LinkFilter::makeLike($query, $protocol); |
77 | 82 | if (!$likeQuery) |
78 | 83 | $this->dieUsage('Invalid query', 'bad_query'); |
79 | 84 | $likeQuery = substr($likeQuery, 0, strpos($likeQuery,'%')+1); |
80 | 85 | $this->addWhere('el_index LIKE ' . $db->addQuotes( $likeQuery )); |
81 | 86 | } |
| 87 | + else if(!is_null($protocol)) |
| 88 | + $this->addWhere('el_index LIKE ' . $db->addQuotes( "$protocol%" )); |
82 | 89 | |
83 | 90 | $prop = array_flip($params['prop']); |
84 | 91 | $fld_ids = isset($prop['ids']); |
— | — | @@ -139,7 +146,7 @@ |
140 | 147 | |
141 | 148 | public function getAllowedParams() { |
142 | 149 | global $wgUrlProtocols; |
143 | | - $protocols = array(); |
| 150 | + $protocols = array(''); |
144 | 151 | foreach ($wgUrlProtocols as $p) { |
145 | 152 | $protocols[] = substr($p, 0, strpos($p,':')); |
146 | 153 | } |
— | — | @@ -159,7 +166,7 @@ |
160 | 167 | ), |
161 | 168 | 'protocol' => array ( |
162 | 169 | ApiBase :: PARAM_TYPE => $protocols, |
163 | | - ApiBase :: PARAM_DFLT => 'http', |
| 170 | + ApiBase :: PARAM_DFLT => '', |
164 | 171 | ), |
165 | 172 | 'query' => null, |
166 | 173 | 'namespace' => array ( |
— | — | @@ -180,8 +187,9 @@ |
181 | 188 | return array ( |
182 | 189 | 'prop' => 'What pieces of information to include', |
183 | 190 | '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', |
186 | 194 | 'namespace' => 'The page namespace(s) to enumerate.', |
187 | 195 | 'limit' => 'How many entries to return.' |
188 | 196 | ); |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -526,6 +526,7 @@ |
527 | 527 | prop={links,templatelinks,langlinks,extlinks,categories,images} |
528 | 528 | * Added flag "top" to list=usercontribs if the user is the last contributor to |
529 | 529 | the page |
| 530 | +* list=exturlusage in "list all links" mode can now filter by protocol |
530 | 531 | |
531 | 532 | === Languages updated in 1.13 === |
532 | 533 | |