API: Correct 'from_namespace' logic in ApiQueryBacklinksprop
authorBrad Jorsch <bjorsch@wikimedia.org>
Wed, 23 Sep 2015 13:31:39 +0000 (09:31 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Wed, 23 Sep 2015 14:14:07 +0000 (10:14 -0400)
The code for the rdnamespace parameter to prop=redirects was trying to
use a nonexistent rd_from_namespace field when miser mode was not
enabled.

Bug: T113453
Change-Id: I7ef77a01c25fec34623b888f439261423cebdaef

includes/api/ApiQueryBacklinksprop.php

index a50d58b..f1a2271 100644 (file)
@@ -143,8 +143,12 @@ class ApiQueryBacklinksprop extends ApiQueryGeneratorBase {
                }
                $miser_ns = null;
                if ( $params['namespace'] !== null ) {
-                       if ( empty( $settings['from_namespace'] ) && $this->getConfig()->get( 'MiserMode' ) ) {
-                               $miser_ns = $params['namespace'];
+                       if ( empty( $settings['from_namespace'] ) ) {
+                               if ( $this->getConfig()->get( 'MiserMode' ) ) {
+                                       $miser_ns = $params['namespace'];
+                               } else {
+                                       $this->addWhereFld( 'page_namespace', $params['namespace'] );
+                               }
                        } else {
                                $this->addWhereFld( "{$p}_from_namespace", $params['namespace'] );
                                if ( !empty( $settings['from_namespace'] ) && count( $params['namespace'] ) > 1 ) {