Last modified: 2014-01-31 07:11:40 UTC
The page MediaWiki:Sidebar includes a template and shows it as expected, but sidebar ignores what was included and shows everything else but a template part of menu. This worked OK in v.1.16.5 (did not check in 1.17)
Hrm... at first I thought this was Bug 33321. Could you try the laetest code from Subversion?
Just tested this. I got the template code "{{doc-important|test}}" as plain text in the sidebar for the first[1] entry, but not for the second. [1] https://translatewiki.net/w/i.php?title=MediaWiki%3ASidebar&diff=3639689&oldid=3423597
Including of Templates workes in 1.17 (I tested) and no longer until 1.18.
It doesnot work in all skins, not only Vector.
someone, I dare not say who, hinted they would look for this regression.
/me hesitates to ask, but... Is there a good use case for putting templates in the sidebar?
(In reply to comment #6) > /me hesitates to ask, but... > > Is there a good use case for putting templates in the sidebar? I use it in wiki farm for common menu options
I combinate it with Extension "myvariables" http://www.mediawiki.org/wiki/Extension:MyVariables User:USERNAME/Sidebar is the personal sidebar for USERNAME. In Mediawiki:Sidebar I include {{CURRENTUSER}}/Sidebar. Worked fine until 1.18.
I've tried it on 1.19.2 the bug is still alive. It's getting annoying... :)
What are exact steps to reproduce the problem?
Since the work I'm currently doing makes extensive use of sidebar modifications, I definitely see a use for this. I'll look into the changes that were involved in 1.18 to cause this.
(In reply to comment #11) > Since the work I'm currently doing makes extensive use of sidebar > modifications, I definitely see a use for this. I'll look into the changes > that were involved in 1.18 to cause this. If I recall, the change had to do with splitting the sidebar into multiple lines before expanding templates, instead of after.
(In reply to comment #10) > What are exact steps to reproduce the problem? The steps are simple: 1. Create a template, for example Template:Test 2. Use it somewhere in Sidebar (page MediaWiki:Sidebar): {{Test}} 3. Save the page You will see the template in content area (just like it suppose to be), but not in the sidebar (like it used to be)
That's where you can see the bug in action: http://en.teopedia.org/lib/MediaWiki:Sidebar
*** Bug 48738 has been marked as a duplicate of this bug. ***
Created attachment 12377 [details] Detailed screenshot of the bug We've got the same problem on 1.19.6. The bug was not in version 1.17.4!
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.
Yesterday I've been working on a fix; and I fixed it by replacing a couple of functions. Note: I use MediaWiki 1.19. All changes are done in the includes/Skin.php. In function buildSidebar() we use the '$wgMemc' variable. This should be replaced to '$parserMemc'. In function addToSidebar( &$bar, $message ) we use the function 'wfMsgForContentNoTrans($message)'. This should be replaced to 'wfMsgForContent($message)'. I think the bug has something to do with it trying to translate things. Anyways; this fixed the problem for me.