r38591 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38590‎ | r38591 | r38592 >
Date:19:36, 4 August 2008
Author:simetrical
Status:old
Tags:
Comment:
Make good-faith effort to run BrokenLink hook in Linker::link(). No parser-test regressions, and it shouldn't change behavior unless Xml::expandAttributes() and Sanitizer::decodeTagAttributes() aren't inverses up to normalization.
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/Xml.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Xml.php
@@ -41,7 +41,7 @@
4242 * Return null if no attributes given.
4343 * @param $attribs Array of attributes for an XML element
4444 */
45 - private static function expandAttributes( $attribs ) {
 45+ public static function expandAttributes( $attribs ) {
4646 $out = '';
4747 if( is_null( $attribs ) ) {
4848 return null;
@@ -682,4 +682,4 @@
683683 return Xml::tags( 'select', $this->attributes, implode( "\n", $this->options ) );
684684 }
685685
686 -}
\ No newline at end of file
 686+}
Index: trunk/phase3/includes/Linker.php
@@ -205,8 +205,24 @@
206206 $text = $this->linkText( $target );
207207 }
208208
 209+ # Compat cruft :(
 210+ if( in_array( 'broken', $options ) ) {
 211+ $hookQuery = wfArrayToCGI( $query );
 212+ $hookUrl = $attribs['href'];
 213+ $hookAttribs = $attribs;
 214+ unset( $hookAttribs['href'] );
 215+ $hookAttribs = Xml::expandAttributes( $hookAttribs );
 216+ $hookPrefix = $hookInside = $hookTrail = '';
 217+ wfRunHooks( 'BrokenLink', array( $this, $target, $hookQuery,
 218+ &$hookUrl, &$hookAttribs, &$hookPrefix, &$text, &$hookInside,
 219+ &$hookTrail ) );
 220+ $attribs = Sanitizer::decodeTagAttributes( $hookAttribs );
 221+ $attribs['href'] = $hookUrl;
 222+ $text = "$hookPrefix$text$hookInside";
 223+ }
 224+
209225 $ret = Xml::openElement( 'a', $attribs )
210 - . $text
 226+ . $text . ( isset( $hookTrail ) ? $hookTrail : '' )
211227 . Xml::closeElement( 'a' );
212228
213229 wfProfileOut( __METHOD__ );

Follow-up revisions

RevisionCommit summaryAuthorDate
r38611Revert r38591 -- "Make good-faith effort to run BrokenLink hook in Linker::li...brion04:56, 5 August 2008

Status & tagging log