SECURITY: API: Don't find links in the middle of api.php links
[lhc/web/wiklou.git] / includes / cache / BacklinkCache.php
index 8eed1a5..d2ec26e 100644 (file)
@@ -156,10 +156,10 @@ class BacklinkCache {
 
        /**
         * Get the backlinks for a given table. Cached in process memory only.
-        * @param $table String
-        * @param $startId Integer|false
-        * @param $endId Integer|false
-        * @param $max Integer|INF
+        * @param string $table
+        * @param int|bool $startId
+        * @param int|bool $endId
+        * @param int|INF $max
         * @return TitleArrayFromResult
         */
        public function getLinks( $table, $startId = false, $endId = false, $max = INF ) {
@@ -274,8 +274,6 @@ class BacklinkCache {
        protected function getConditions( $table ) {
                $prefix = $this->getPrefix( $table );
 
-               // @todo FIXME: imagelinks and categorylinks do not rely on getNamespace,
-               // they could be moved up for nicer case statements
                switch ( $table ) {
                        case 'pagelinks':
                        case 'templatelinks':
@@ -297,14 +295,9 @@ class BacklinkCache {
                                );
                                break;
                        case 'imagelinks':
-                               $conds = array(
-                                       'il_to' => $this->title->getDBkey(),
-                                       "page_id={$prefix}_from"
-                               );
-                               break;
                        case 'categorylinks':
                                $conds = array(
-                                       'cl_to' => $this->title->getDBkey(),
+                                       "{$prefix}_to" => $this->title->getDBkey(),
                                        "page_id={$prefix}_from"
                                );
                                break;
@@ -433,7 +426,7 @@ class BacklinkCache {
                        $cacheEntry['numRows'] += $partitions['numRows'];
                        $cacheEntry['batches'] = array_merge( $cacheEntry['batches'], $partitions['batches'] );
                        if ( count( $partitions['batches'] ) ) {
-                               list( $lStart, $lEnd ) = end( $partitions['batches'] );
+                               list( , $lEnd ) = end( $partitions['batches'] );
                                $start = $lEnd + 1; // pick up after this inclusive range
                        }
                } while ( $partitions['numRows'] >= $selectSize );