Merge "maintenance: Document secondary purpose of --server"
[lhc/web/wiklou.git] / includes / specials / SpecialWhatlinkshere.php
index 3349854..3080fbf 100644 (file)
@@ -21,6 +21,8 @@
  * @todo Use some variant of Pager or something; the pagination here is lousy.
  */
 
+use Wikimedia\Rdbms\IDatabase;
+
 /**
  * Implements Special:Whatlinkshere
  *
@@ -160,7 +162,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                        ];
                        $on['rd_namespace'] = $target->getNamespace();
                        // Inner LIMIT is 2X in case of stale backlinks with wrong namespaces
-                       $subQuery = $dbr->selectSQLText(
+                       $subQuery = $dbr->buildSelectSubquery(
                                [ $table, 'redirect', 'page' ],
                                [ $fromCol, 'rd_from' ],
                                $conds[$table],
@@ -173,7 +175,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                                ]
                        );
                        return $dbr->select(
-                               [ 'page', 'temp_backlink_range' => "($subQuery)" ],
+                               [ 'page', 'temp_backlink_range' => $subQuery ],
                                [ 'page_id', 'page_namespace', 'page_title', 'rd_from', 'page_is_redirect' ],
                                [],
                                __CLASS__ . '::showIndirectLinks',
@@ -378,11 +380,15 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
 
                $linkRenderer = $this->getLinkRenderer();
 
+               if ( $text !== null ) {
+                       $text = new HtmlArmor( $text );
+               }
+
                // always show a "<- Links" link
                $links = [
                        'links' => $linkRenderer->makeKnownLink(
                                $title,
-                               new HtmlArmor( $text ),
+                               $text,
                                [],
                                [ 'target' => $target->getPrefixedText() ]
                        ),
@@ -395,9 +401,13 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
                        // check, if the content model is editable through action=edit
                        ContentHandler::getForTitle( $target )->supportsDirectEditing()
                ) {
+                       if ( $editText !== null ) {
+                               $editText = new HtmlArmor( $editText );
+                       }
+
                        $links['edit'] = $linkRenderer->makeKnownLink(
                                $target,
-                               new HtmlArmor( $editText ),
+                               $editText,
                                [],
                                [ 'action' => 'edit' ]
                        );
@@ -408,9 +418,13 @@ class SpecialWhatLinksHere extends IncludableSpecialPage {
        }
 
        function makeSelfLink( $text, $query ) {
+               if ( $text !== null ) {
+                       $text = new HtmlArmor( $text );
+               }
+
                return $this->getLinkRenderer()->makeKnownLink(
                        $this->selfTitle,
-                       new HtmlArmor( $text ),
+                       $text,
                        [],
                        $query
                );