Parse sidebar message for main page when cache is enabled
authorumherirrender <umherirrender_de.wp@web.de>
Sun, 10 Jul 2016 20:17:27 +0000 (22:17 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Sun, 10 Jul 2016 20:17:27 +0000 (22:17 +0200)
When the sidebar cache is enabled, parse the messages for the links and
link text of the sidebar with the main page as title, because variable
like FULLPAGENAME would vary on page, but cache does not.

Change-Id: I0bbb05f1abe4be1a61f520d647c8ca696d184ccf

includes/skins/Skin.php

index 729f564..64d2f8b 100644 (file)
@@ -1241,6 +1241,8 @@ abstract class Skin extends ContextSource {
                $lines = explode( "\n", $text );
 
                $heading = '';
+               $messageTitle = $this->getConfig()->get( 'EnableSidebarCache' )
+                       ? Title::newMainPage() : $this->getTitle();
 
                foreach ( $lines as $line ) {
                        if ( strpos( $line, '*' ) !== 0 ) {
@@ -1257,7 +1259,7 @@ abstract class Skin extends ContextSource {
                                $line = trim( $line, '* ' );
 
                                if ( strpos( $line, '|' ) !== false ) { // sanity check
-                                       $line = MessageCache::singleton()->transform( $line, false, null, $this->getTitle() );
+                                       $line = MessageCache::singleton()->transform( $line, false, null, $messageTitle );
                                        $line = array_map( 'trim', explode( '|', $line, 2 ) );
                                        if ( count( $line ) !== 2 ) {
                                                // Second sanity check, could be hit by people doing
@@ -1267,7 +1269,7 @@ abstract class Skin extends ContextSource {
 
                                        $extraAttribs = [];
 
-                                       $msgLink = $this->msg( $line[0] )->inContentLanguage();
+                                       $msgLink = $this->msg( $line[0] )->title( $messageTitle )->inContentLanguage();
                                        if ( $msgLink->exists() ) {
                                                $link = $msgLink->text();
                                                if ( $link == '-' ) {
@@ -1276,7 +1278,7 @@ abstract class Skin extends ContextSource {
                                        } else {
                                                $link = $line[0];
                                        }
-                                       $msgText = $this->msg( $line[1] );
+                                       $msgText = $this->msg( $line[1] )->title( $messageTitle );
                                        if ( $msgText->exists() ) {
                                                $text = $msgText->text();
                                        } else {