From 0b4930fa7a5b5cfbcdbd35a00d328e5bae37c896 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 16 Jul 2008 10:15:47 +0000 Subject: [PATCH] Revert r37741 for now "Changed getInternalLinkAttributesInternal parameters: now accepts Title object if available, passes to hook. Also reordered some code in makeKnownLinkObj so that said hook can mangle the Title object. Reordering should have no other side-effects." This seems a bit icky and inconsistent. If it's necessary to pass titles around here, it should be done consistently, with appropriate fixups and refactoring to the old spaghetti code. --- docs/hooks.txt | 7 ------- includes/Linker.php | 23 +++++++++++------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 274018293b..2217a5ea58 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -753,13 +753,6 @@ $lang: laguage code (string) $specialPageAliases: associative array of magic words synonyms $lang: laguage code (string) -'LinkerLinkAttributes': At the end of Linker::getLinkAttributesInternal() just before the return -&$this: Linker object -&$nt: Title object of link target, or null -$title: 'title' attribute string -$class: 'class' attribute string -&$result: Final attribute string - 'LinkerMakeExternalImage': At the end of Linker::makeExternalImage() just before the return &$url: the image url &$alt: the image's alt text diff --git a/includes/Linker.php b/includes/Linker.php index ecf50ef243..03e7a9eb22 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -34,7 +34,7 @@ class Linker { * string is passed, which is the default value, defaults to 'external'. */ function getExternalLinkAttributes( $title, $unused = null, $class='' ) { - return $this->getLinkAttributesInternal( null, $title, $class, 'external' ); + return $this->getLinkAttributesInternal( $title, $class, 'external' ); } /** @@ -56,7 +56,7 @@ class Linker { $title = $wgContLang->checkTitleEncoding( $title ); $title = preg_replace( '/[\\x00-\\x1f]/', ' ', $title ); - return $this->getLinkAttributesInternal( null, $title, $class, 'external' ); + return $this->getLinkAttributesInternal( $title, $class, 'external' ); } /** @@ -71,7 +71,7 @@ class Linker { function getInternalLinkAttributes( $title, $unused = null, $class='' ) { $title = urldecode( $title ); $title = str_replace( '_', ' ', $title ); - return $this->getLinkAttributesInternal( null, $title, $class ); + return $this->getLinkAttributesInternal( $title, $class ); } /** @@ -88,13 +88,13 @@ class Linker { if( $title === false ) { $title = $nt->getPrefixedText(); } - return $this->getLinkAttributesInternal( $nt, $title, $class ); + return $this->getLinkAttributesInternal( $title, $class ); } /** * Common code for getLinkAttributesX functions */ - private function getLinkAttributesInternal( $nt, $title, $class, $classDefault = false ) { + private function getLinkAttributesInternal( $title, $class, $classDefault = false ) { $title = htmlspecialchars( $title ); if( $class === '' and $classDefault !== false ) { # FIXME: Parameter defaults the hard way! We should just have @@ -108,7 +108,6 @@ class Linker { $r .= " class=\"$class\""; } $r .= " title=\"$title\""; - wfRunHooks( 'LinkerLinkAttributes', array( &$this, &$nt, $title, $class, &$r ) ); return $r; } @@ -324,12 +323,6 @@ class Linker { $nt = $this->normaliseSpecialPage( $title ); - if ( $text == '' ) { - $text = htmlspecialchars( $nt->getPrefixedText() ); - } - if ( $style == '' ) { - $style = $this->getInternalLinkAttributesObj( $nt, $text ); - } $u = $nt->escapeLocalURL( $query ); if ( $nt->getFragment() != '' ) { if( $nt->getPrefixedDbkey() == '' ) { @@ -340,6 +333,12 @@ class Linker { } $u .= $nt->getFragmentForURL(); } + if ( $text == '' ) { + $text = htmlspecialchars( $nt->getPrefixedText() ); + } + if ( $style == '' ) { + $style = $this->getInternalLinkAttributesObj( $nt, $text ); + } if ( $aprops !== '' ) $aprops = ' ' . $aprops; -- 2.20.1