https://bugzilla.wikimedia.org/show_bug.cgi?id=33766

--- Comment #17 from Youri van den Bogert <[email protected]> ---
In Includes/Skin.php search for function: addToSidebarPlain

If you have version 1.17* you'll probally see a elseif searching for '{{'. On
the newer version, there is nothing thats searches for a '{{'


1.17.x function:
    /**
     * Add content from plain text
     * @since 1.17
     * @param &$bar array
     * @param $text string
     */
    function addToSidebarPlain( &$bar, $text ) {
        $lines = explode( "\n", $text );
        $wikiBar = array(); # We need to handle the wikitext on a different
variable, to avoid trying to do an array operation on text, which would be a
fatal error.

        $heading = '';

        foreach ( $lines as $line ) {
            if ( strpos( $line, '*' ) !== 0 ) {
                continue;
            }

            if ( strpos( $line, '**' ) !== 0 ) {
                $heading = trim( $line, '* ' );
                if ( !array_key_exists( $heading, $bar ) ) {
                    $bar[$heading] = array();
                }
            } else {
                $line = trim( $line, '* ' );

                if ( strpos( $line, '|' ) !== false ) { // sanity check
                    $line = array_map( 'trim', explode( '|', $line, 2 ) );
                    $link = wfMsgForContent( $line[0] );

                    if ( $link == '-' ) {
                        continue;
                    }

                    $text = wfMsgExt( $line[1], 'parsemag' );

                    if ( wfEmptyMsg( $line[1], $text ) ) {
                        $text = $line[1];
                    }

                    if ( wfEmptyMsg( $line[0], $link ) ) {
                        $link = $line[0];
                    }

                    if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link )
) {
                        $href = $link;
                    } else {
                        $title = Title::newFromText( $link );

                        if ( $title ) {
                            $title = $title->fixSpecialName();
                            $href = $title->getLocalURL();
                        } else {
                            $href = 'INVALID-TITLE';
                        }
                    }

                    $bar[$heading][] = array(
                        'text' => $text,
                        'href' => $href,
                        'id' => 'n-' . strtr( $line[1], ' ', '-' ),
                        'active' => false
                    );
                } else if ( ( substr( $line, 0, 2 ) == '{{' ) && ( substr(
$line, -2 ) == '}}' ) ) {
                    global $wgParser, $wgTitle;

                    $line = substr( $line, 2, strlen( $line ) - 4 );

                    $options = new ParserOptions();
                    $options->setEditSection( false );
                    $options->setInterfaceMessage( true );
                    $wikiBar[$heading] = $wgParser->parse(
wfMsgForContentNoTrans( $line ) , $wgTitle, $options )->getText();
                } else {
                    continue;
                }
            }
        }

        if ( count( $wikiBar ) > 0 ) {
            $bar = array_merge( $bar, $wikiBar );
        }

        return $bar;
    }


1.19.x function:
    /**
     * Add content from plain text
     * @since 1.17
     * @param $bar array
     * @param $text string
     * @return Array
     */
    function addToSidebarPlain( &$bar, $text ) {
        $lines = explode( "\n", $text );

        $heading = '';

        foreach ( $lines as $line ) {
            if ( strpos( $line, '*' ) !== 0 ) {
                continue;
            }
            $line = rtrim( $line, "\r" ); // for Windows compat

            if ( strpos( $line, '**' ) !== 0 ) {
                $heading = trim( $line, '* ' );
                if ( !array_key_exists( $heading, $bar ) ) {
                    $bar[$heading] = array();
                }
            } else {
                $line = trim( $line, '* ' );

                if ( strpos( $line, '|' ) !== false ) { // sanity check
                    $line = MessageCache::singleton()->transform( $line, false,
null, $this->getTitle() );
                    $line = array_map( 'trim', explode( '|', $line, 2 ) );
                    if ( count( $line ) !== 2 ) {
                        // Second sanity check, could be hit by people doing
                        // funky stuff with parserfuncs... (bug 33321)
                        continue;
                    }

                    $extraAttribs = array();

                    $msgLink = $this->msg( $line[0] )->inContentLanguage();
                    if ( $msgLink->exists() ) {
                        $link = $msgLink->text();
                        if ( $link == '-' ) {
                            continue;
                        }
                    } else {
                        $link = $line[0];
                    }
                    $msgText = $this->msg( $line[1] );
                    if ( $msgText->exists() ) {
                        $text = $msgText->text();
                    } else {
                        $text = $line[1];
                    }

                    if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link )
) {
                        $href = $link;

                        // Parser::getExternalLinkAttribs won't work here
because of the Namespace things
                        global $wgNoFollowLinks, $wgNoFollowDomainExceptions;
                        if ( $wgNoFollowLinks && !wfMatchesDomainList( $href,
$wgNoFollowDomainExceptions ) ) {
                            $extraAttribs['rel'] = 'nofollow';
                        }

                        global $wgExternalLinkTarget;
                        if ( $wgExternalLinkTarget) {
                            $extraAttribs['target'] = $wgExternalLinkTarget;
                        }
                    } else {
                        $title = Title::newFromText( $link );

                        if ( $title ) {
                            $title = $title->fixSpecialName();
                            $href = $title->getLinkURL();
                        } else {
                            $href = 'INVALID-TITLE';
                        }
                    }

                    $bar[$heading][] = array_merge( array(
                        'text' => $text,
                        'href' => $href,
                        'id' => 'n-' . Sanitizer::escapeId( strtr( $line[1], '
', '-' ), 'noninitial' ),
                        'active' => false
                    ), $extraAttribs );
                } else {
                    continue;
                }
            }
        }

        return $bar;
    }


Compare versions at diffnow.com and  see the differences.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to