From: Florian Date: Thu, 23 Jul 2015 16:15:08 +0000 (+0200) Subject: Special:WhatLinksHere Don't show edit links for non-direct-editing pages X-Git-Tag: 1.31.0-rc.0~10596 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=ee95d494c9f4db1edb538f7d94398f9f96e1ce7c;p=lhc%2Fweb%2Fwiklou.git Special:WhatLinksHere Don't show edit links for non-direct-editing pages It's possible, that pages links to a page, which aren't editable directly through action=edit. Don't show an edit link for such pages. Bug: T106680 Change-Id: I01ff6dbd5b4e9fff84795f7c3d8ada23c09c7ae8 --- diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php index 69a8074609..5db81d4f93 100644 --- a/includes/specials/SpecialWhatlinkshere.php +++ b/includes/specials/SpecialWhatlinkshere.php @@ -267,6 +267,14 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { } $prevId = $from; + // use LinkBatch to make sure, that all required data (associated with Titles) + // is loaded in one query + $lb = new LinkBatch(); + foreach ( $rows as $row ) { + $lb->add( $row->page_namespace, $row->page_title ); + } + $lb->execute(); + if ( $level == 0 ) { if ( !$this->including() ) { $out->addHTML( $this->whatlinkshereForm() ); @@ -376,23 +384,33 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { $title = $this->getPageTitle(); } - $editLink = ''; - if ( $this->getUser()->isAllowed( 'edit' ) ) { - $editLink = $this->msg( 'pipe-separator' )->escaped() . - Linker::linkKnown( - $target, - $editText, - array(), - array( 'action' => 'edit' ) - ); + // always show a "<- Links" link + $links = array( + 'links' => Linker::linkKnown( + $title, + $text, + array(), + array( 'target' => $target->getPrefixedText() ) + ), + ); + + // if the page is editable, add an edit link + if ( + // check user permissions + $this->getUser()->isAllowed( 'edit' ) && + // check, if the content model is editable through action=edit + ContentHandler::getForTitle( $target )->supportsDirectEditing() + ) { + $links['edit'] = Linker::linkKnown( + $target, + $editText, + array(), + array( 'action' => 'edit' ) + ); } - return Linker::linkKnown( - $title, - $text, - array(), - array( 'target' => $target->getPrefixedText() ) - ) . $editLink; + // build the links html + return $this->getLanguage()->pipeList( $links ); } function makeSelfLink( $text, $query ) {