Revert r38591 -- "Make good-faith effort to run BrokenLink hook in Linker::link(...
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 5 Aug 2008 04:56:29 +0000 (04:56 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 5 Aug 2008 04:56:29 +0000 (04:56 +0000)
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. :)

includes/Linker.php
includes/Xml.php

index 476245c..b913ebf 100644 (file)
@@ -205,24 +205,8 @@ class Linker {
                        $text = $this->linkText( $target );
                }
 
-               # Compat cruft :(
-               if( in_array( 'broken', $options ) ) {
-                       $hookQuery = wfArrayToCGI( $query );
-                       $hookUrl = $attribs['href'];
-                       $hookAttribs = $attribs;
-                       unset( $hookAttribs['href'] );
-                       $hookAttribs = Xml::expandAttributes( $hookAttribs );
-                       $hookPrefix = $hookInside = $hookTrail = '';
-                       wfRunHooks( 'BrokenLink', array( $this, $target, $hookQuery,
-                               &$hookUrl, &$hookAttribs, &$hookPrefix, &$text, &$hookInside,
-                               &$hookTrail ) );
-                       $attribs = Sanitizer::decodeTagAttributes( $hookAttribs );
-                       $attribs['href'] = $hookUrl;
-                       $text = "$hookPrefix$text$hookInside";
-               }
-
                $ret = Xml::openElement( 'a', $attribs )
-                       . $text . ( isset( $hookTrail ) ? $hookTrail : '' )
+                       . $text
                        . Xml::closeElement( 'a' );
 
                wfProfileOut( __METHOD__ );
index 1551878..7db9ee8 100644 (file)
@@ -41,7 +41,7 @@ class Xml {
         * Return null if no attributes given.
         * @param $attribs Array of attributes for an XML element
         */
-       public static function expandAttributes( $attribs ) {
+       private static function expandAttributes( $attribs ) {
                $out = '';
                if( is_null( $attribs ) ) {
                        return null;
@@ -682,4 +682,4 @@ class XmlSelect {
                return Xml::tags( 'select', $this->attributes, implode( "\n", $this->options ) );
        }
 
-}
+}
\ No newline at end of file