Revert ApiQueryExtLinksUsage.php back to r32772: Forgot to do svn revert . on working...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 4 Apr 2008 11:51:55 +0000 (11:51 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Fri, 4 Apr 2008 11:51:55 +0000 (11:51 +0000)
includes/api/ApiQueryExtLinksUsage.php

index 08e09cb..2919adb 100644 (file)
@@ -54,29 +54,30 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                
                // Find the right prefix
                global $wgUrlProtocols;
-               foreach ($wgUrlProtocols as $p) {
-                       if( substr( $p, 0, strlen( $protocol ) ) === $protocol ) {
-                               $protocol = $p;
-                               break;
+               if(!is_null($protocol) && $protocol != '' && !in_array($protocol, $wgUrlProtocols))
+               {
+                       foreach ($wgUrlProtocols as $p) {
+                               if( substr( $p, 0, strlen( $protocol ) ) === $protocol ) {
+                                       $protocol = $p;
+                                       break;
+                               }
                        }
                }
                
-               $likeQuery = false;
-               if (!is_null($query)) {
+               $db = $this->getDb();
+               $this->addTables(array('page','externallinks'));        // must be in this order for 'USE INDEX' 
+               $this->addOption('USE INDEX', 'el_index');
+               $this->addWhere('page_id=el_from');
+               $this->addWhereFld('page_namespace', $params['namespace']);
+
+               if(!is_null($query) || $query != '')
+               {
                        $likeQuery = LinkFilter::makeLike($query , $protocol);
                        if (!$likeQuery)
                                $this->dieUsage('Invalid query', 'bad_query');
                        $likeQuery = substr($likeQuery, 0, strpos($likeQuery,'%')+1);
-               }
-
-               $this->addTables(array('page','externallinks'));        // must be in this order for 'USE INDEX' 
-               $this->addOption('USE INDEX', 'el_index');
-
-               $db = $this->getDB();
-               $this->addWhere('page_id=el_from');
-               if ($likeQuery)
                        $this->addWhere('el_index LIKE ' . $db->addQuotes( $likeQuery ));
-               $this->addWhereFld('page_namespace', $params['namespace']);
+               }
 
                $prop = array_flip($params['prop']);
                $fld_ids = isset($prop['ids']);
@@ -180,7 +181,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                        'prop' => 'What pieces of information to include',
                        'offset' => 'Used for paging. Use the value returned for "continue"',
                        'protocol' => 'Protocol of the url',
-                       'query' => 'Search string without protocol. See [[Special:LinkSearch]]',
+                       '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.'
                );