r38611 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r38610‎ | r38611 | r38612 >
Date:04:56, 5 August 2008
Author:brion
Status:old
Tags:
Comment:
Revert r38591 -- "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."

IMHO this is an excellent opportunity to kill a horrible interface and replace it with a sane one. Note the only use of the BrokenLink hook currently in our SVN is in SemanticForms:

/**
* Sets the URL for form-based adding of a nonexistent (broken-linked, AKA
* red-linked) page
*/
function sffSetBrokenLink(&$linker, $title, $query, &$u, &$style, &$prefix, &$text, &$inside, &$trail) {
$link = sffAddDataLink($title);
if ($link != '')
$u = $link;
return true;
}

In the unlikely event that anybody else is really needing the exact hook details, I'm sure there's a much nicer, more future-friendly way to do it. Make a new hook and let these hypothetical extensions fix themselves up. :)
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 - public static function expandAttributes( $attribs ) {
 45+ private 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 -}
 686+}
\ No newline at end of file
Index: trunk/phase3/includes/Linker.php
@@ -205,24 +205,8 @@
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 -
225209 $ret = Xml::openElement( 'a', $attribs )
226 - . $text . ( isset( $hookTrail ) ? $hookTrail : '' )
 210+ . $text
227211 . Xml::closeElement( 'a' );
228212
229213 wfProfileOut( __METHOD__ );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r38591Make good-faith effort to run BrokenLink hook in Linker::link(). No parser-t...simetrical19:36, 4 August 2008

Status & tagging log