X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialWhatlinkshere.php;h=0e5ffce4ffd8898f0ea61ed6d95ba4cf1a71f605;hb=323a2909ba1f43407ccba8bc1fadf2d25f2de488;hp=be77e627462fd26f060a3e64f3078b067f0f4c04;hpb=9c092814c7f275db78a6ed769aa76fdd87709c60;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php index be77e62746..0e5ffce4ff 100644 --- a/includes/specials/SpecialWhatlinkshere.php +++ b/includes/specials/SpecialWhatlinkshere.php @@ -127,20 +127,13 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { 'il_to' => $target->getDBkey(), ); - $useLinkNamespaceDBFields = $this->getConfig()->get( 'UseLinkNamespaceDBFields' ); $namespace = $this->opts->getValue( 'namespace' ); $invert = $this->opts->getValue( 'invert' ); $nsComparison = ( $invert ? '!= ' : '= ' ) . $dbr->addQuotes( $namespace ); if ( is_int( $namespace ) ) { - if ( $useLinkNamespaceDBFields ) { - $conds['pagelinks'][] = "pl_from_namespace $nsComparison"; - $conds['templatelinks'][] = "tl_from_namespace $nsComparison"; - $conds['imagelinks'][] = "il_from_namespace $nsComparison"; - } else { - $conds['pagelinks'][] = "page_namespace $nsComparison"; - $conds['templatelinks'][] = "page_namespace $nsComparison"; - $conds['imagelinks'][] = "page_namespace $nsComparison"; - } + $conds['pagelinks'][] = "pl_from_namespace $nsComparison"; + $conds['templatelinks'][] = "tl_from_namespace $nsComparison"; + $conds['imagelinks'][] = "il_from_namespace $nsComparison"; } if ( $from ) { @@ -155,8 +148,8 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { $conds['pagelinks'][] = 'rd_from is NOT NULL'; } - $queryFunc = function ( $dbr, $table, $fromCol ) use ( - $conds, $target, $limit, $useLinkNamespaceDBFields + $queryFunc = function ( IDatabase $dbr, $table, $fromCol ) use ( + $conds, $target, $limit ) { // Read an extra row as an at-end check $queryLimit = $limit + 1; @@ -165,16 +158,15 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { 'rd_title' => $target->getDBkey(), 'rd_interwiki = ' . $dbr->addQuotes( '' ) . ' OR rd_interwiki IS NULL' ); - if ( $useLinkNamespaceDBFields ) { // migration check - $on['rd_namespace'] = $target->getNamespace(); - } + $on['rd_namespace'] = $target->getNamespace(); // Inner LIMIT is 2X in case of stale backlinks with wrong namespaces $subQuery = $dbr->selectSqlText( - array( $table, 'page', 'redirect' ), + array( $table, 'redirect', 'page' ), array( $fromCol, 'rd_from' ), $conds[$table], __CLASS__ . '::showIndirectLinks', - array( 'ORDER BY' => $fromCol, 'LIMIT' => 2 * $queryLimit ), + // Force JOIN order per T106682 to avoid large filesorts + array( 'ORDER BY' => $fromCol, 'LIMIT' => 2 * $queryLimit, 'STRAIGHT_JOIN' ), array( 'page' => array( 'INNER JOIN', "$fromCol = page_id" ), 'redirect' => array( 'LEFT JOIN', $on ) @@ -267,6 +259,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() ); @@ -314,7 +314,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { static $msgcache = null; if ( $msgcache === null ) { static $msgs = array( 'isredirect', 'istemplate', 'semicolon-separator', - 'whatlinkshere-links', 'isimage' ); + 'whatlinkshere-links', 'isimage', 'editlink' ); $msgcache = array(); foreach ( $msgs as $msg ) { $msgcache[$msg] = $this->msg( $msg )->escaped(); @@ -355,7 +355,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { } # Space for utilities links, with a what-links-here link provided - $wlhLink = $this->wlhLink( $nt, $msgcache['whatlinkshere-links'] ); + $wlhLink = $this->wlhLink( $nt, $msgcache['whatlinkshere-links'], $msgcache['editlink'] ); $wlh = Xml::wrapClass( $this->msg( 'parentheses' )->rawParams( $wlhLink )->escaped(), 'mw-whatlinkshere-tools' @@ -370,18 +370,39 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { return Xml::closeElement( 'ul' ); } - protected function wlhLink( Title $target, $text ) { + protected function wlhLink( Title $target, $text, $editText ) { static $title = null; if ( $title === null ) { $title = $this->getPageTitle(); } - return Linker::linkKnown( - $title, - $text, - array(), - array( 'target' => $target->getPrefixedText() ) + // 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' ) + ); + } + + // build the links html + return $this->getLanguage()->pipeList( $links ); } function makeSelfLink( $text, $query ) {