Unbreak Special:WhatLinksHere for $wgUseLinkNamespaceDBFields=false
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 29 Jul 2014 01:16:40 +0000 (18:16 -0700)
committerReedy <reedy@wikimedia.org>
Wed, 30 Jul 2014 23:32:07 +0000 (23:32 +0000)
* Usage of the namespace selector gave a query error.
  This fixes b8c038f6784ef08205f7cf6d7cc11462140e3fa2.
* Also handle a high amount of outdated *_namespace fields better.

Change-Id: I57e51f18ae749ac64413a612d6070fab29dff51f

includes/specials/SpecialWhatlinkshere.php

index b92ede5..60ac02f 100644 (file)
@@ -163,14 +163,17 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                        if ( $wgUseLinkNamespaceDBFields ) { // migration check
                                $on['rd_namespace'] = $target->getNamespace();
                        }
-                       // Inner LIMIT is 2X in case of stale backlinks with no page
+                       // Inner LIMIT is 2X in case of stale backlinks with wrong namespaces
                        $subQuery = $dbr->selectSqlText(
-                               array( $table, 'redirect' ),
+                               array( $table, 'page', 'redirect' ),
                                array( $fromCol, 'rd_from' ),
                                $conds[$table],
                                __CLASS__ . '::showIndirectLinks',
                                array( 'ORDER BY' => $fromCol, 'LIMIT' => 2 * $queryLimit ),
-                               array( 'redirect' => array( 'LEFT JOIN', $on ) )
+                               array(
+                                       'page' => array( 'INNER JOIN', "$fromCol = page_id" ),
+                                       'redirect' => array( 'LEFT JOIN', $on )
+                               )
                        );
                        return $dbr->select(
                                array( 'page', 'temp_backlink_range' => "($subQuery)" ),