Merge "Fix \n handling for HTMLUsersMultiselectField"
[lhc/web/wiklou.git] / includes / api / ApiQueryBacklinksprop.php
index ef7b9af..1db15f8 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Created on Aug 19, 2014
  *
- * Copyright © 2014 Brad Jorsch <bjorsch@wikimedia.org>
+ * Copyright © 2014 Wikimedia Foundation and contributors
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -104,6 +104,13 @@ class ApiQueryBacklinksprop extends ApiQueryGeneratorBase {
                $titles = $pageSet->getGoodAndMissingTitles();
                $map = $pageSet->getGoodAndMissingTitlesByNamespace();
 
+               // Add in special pages, they can theoretically have backlinks too.
+               // (although currently they only do for prop=redirects)
+               foreach ( $pageSet->getSpecialTitles() as $id => $title ) {
+                       $titles[] = $title;
+                       $map[$title->getNamespace()][$title->getDBkey()] = $id;
+               }
+
                // Determine our fields to query on
                $p = $settings['prefix'];
                $hasNS = !isset( $settings['to_namespace'] );
@@ -220,8 +227,9 @@ class ApiQueryBacklinksprop extends ApiQueryGeneratorBase {
                $this->addFieldsIf( 'page_namespace', $miser_ns !== null );
 
                if ( $hasNS ) {
-                       $lb = new LinkBatch( $titles );
-                       $this->addWhere( $lb->constructSet( $p, $db ) );
+                       // Can't use LinkBatch because it throws away Special titles.
+                       // And we already have the needed data structure anyway.
+                       $this->addWhere( $db->makeWhereFrom2d( $map, $bl_namespace, $bl_title ) );
                } else {
                        $where = [];
                        foreach ( $titles as $t ) {
@@ -424,6 +432,6 @@ class ApiQueryBacklinksprop extends ApiQueryGeneratorBase {
 
        public function getHelpUrls() {
                $name = ucfirst( $this->getModuleName() );
-               return "https://www.mediawiki.org/wiki/API:{$name}";
+               return "https://www.mediawiki.org/wiki/Special:MyLanguage/API:{$name}";
        }
 }