Merge "Skin: Make skins aware of their registered skin name"
[lhc/web/wiklou.git] / includes / api / ApiQueryLinks.php
index 29c0b74..2f75e76 100644 (file)
@@ -34,7 +34,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
        const LINKS = 'links';
        const TEMPLATES = 'templates';
 
-       private $table, $prefix, $helpUrl;
+       private $table, $prefix, $titlesParam, $helpUrl;
 
        public function __construct( ApiQuery $query, $moduleName ) {
                switch ( $moduleName ) {
@@ -89,7 +89,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                $this->addWhereFld( $this->prefix . '_from', array_keys( $this->getPageSet()->getGoodTitles() ) );
                $this->addWhereFld( $this->prefix . '_namespace', $params['namespace'] );
 
-               if ( !is_null( $params[$this->titlesParam] ) ) {
+               if ( $params[$this->titlesParam] ) {
                        $lb = new LinkBatch;
                        foreach ( $params[$this->titlesParam] as $t ) {
                                $title = Title::newFromText( $t );
@@ -102,6 +102,9 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                        $cond = $lb->constructSet( $this->prefix, $this->getDB() );
                        if ( $cond ) {
                                $this->addWhere( $cond );
+                       } else {
+                               // No titles so no results
+                               return;
                        }
                }
 
@@ -137,7 +140,6 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
 
                $order[] = $this->prefix . '_title' . $sort;
                $this->addOption( 'ORDER BY', $order );
-               $this->addOption( 'USE INDEX', $this->prefix . '_from' );
                $this->addOption( 'LIMIT', $params['limit'] + 1 );
 
                $res = $this->select( __METHOD__ );