Revert r37642 for now ('Added possibility to filter by protocol in "list all links...
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 15 Jul 2008 20:51:07 +0000 (20:51 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 15 Jul 2008 20:51:07 +0000 (20:51 +0000)
* 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')

RELEASE-NOTES
includes/api/ApiQueryExtLinksUsage.php

index 38113b9..7c7be85 100644 (file)
@@ -540,7 +540,6 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   prop={links,templatelinks,langlinks,extlinks,categories,images}
 * Added flag "top" to list=usercontribs if the user is the last contributor to
   the page
-* list=exturlusage in "list all links" mode can now filter by protocol
 
 === Languages updated in 1.13 ===
 
index d2de777..34e24f3 100644 (file)
@@ -54,7 +54,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
 
                // Find the right prefix
                global $wgUrlProtocols;
-               if(!is_null($protocol) && !empty($protocol) && !in_array($protocol, $wgUrlProtocols))
+               if(!is_null($protocol) && $protocol != '' && !in_array($protocol, $wgUrlProtocols))
                {
                        foreach ($wgUrlProtocols as $p) {
                                if( substr( $p, 0, strlen( $protocol ) ) === $protocol ) {
@@ -63,8 +63,6 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                                }
                        }
                }
-               else
-                       $protocol = null;
 
                $db = $this->getDb();
                $this->addTables(array('page','externallinks'));        // must be in this order for 'USE INDEX'
@@ -74,17 +72,12 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
 
                if(!is_null($query) || $query != '')
                {
-                       if(is_null($protocol))
-                               $protocol = 'http';
-
-                       $likeQuery = LinkFilter::makeLike($query, $protocol);
+                       $likeQuery = LinkFilter::makeLike($query , $protocol);
                        if (!$likeQuery)
                                $this->dieUsage('Invalid query', 'bad_query');
                        $likeQuery = substr($likeQuery, 0, strpos($likeQuery,'%')+1);
                        $this->addWhere('el_index LIKE ' . $db->addQuotes( $likeQuery ));
                }
-               else if(!is_null($protocol))
-                       $this->addWhere('el_index LIKE ' . $db->addQuotes( "$protocol%" ));
 
                $prop = array_flip($params['prop']);
                $fld_ids = isset($prop['ids']);
@@ -146,7 +139,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
 
        public function getAllowedParams() {
                global $wgUrlProtocols;
-               $protocols = array('');
+               $protocols = array();
                foreach ($wgUrlProtocols as $p) {
                        $protocols[] = substr($p, 0, strpos($p,':'));
                }
@@ -166,7 +159,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                        ),
                        'protocol' => array (
                                ApiBase :: PARAM_TYPE => $protocols,
-                               ApiBase :: PARAM_DFLT => '',
+                               ApiBase :: PARAM_DFLT => 'http',
                        ),
                        'query' => null,
                        'namespace' => array (
@@ -187,9 +180,8 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                return array (
                        'prop' => 'What pieces of information to include',
                        'offset' => 'Used for paging. Use the value returned for "continue"',
-                       'protocol' => array(    'Protocol of the url. If empty and euquery set, the protocol is http.',
-                                               'Leave both this and euquery empty to list all external links'),
-                       'query' => 'Search string without protocol. See [[Special:LinkSearch]]. Leave empty to list all external links',
+                       'protocol' => 'Protocol of the url',
+                       'query' => 'Search string without protocol. See [[Special:LinkSearch]]. Leave empty to list all external links (euprotocol will be ignored)',
                        'namespace' => 'The page namespace(s) to enumerate.',
                        'limit' => 'How many entries to return.'
                );