From f70dc2c88d38ec9dfd742022b07f290c34b6fb56 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Sun, 10 Jul 2016 22:17:27 +0200 Subject: [PATCH] Parse sidebar message for main page when cache is enabled 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 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index 729f56451b..64d2f8bd45 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -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 { -- 2.20.1