r53172 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53171‎ | r53172 | r53173 >
Date:15:34, 13 July 2009
Author:werdna
Status:deferred
Tags:
Comment:
Only write scripts and styles to the page once
Modified paths:
  • /trunk/extensions/LiquidThreads/classes/LqtDispatch.php (modified) (history)
  • /trunk/extensions/LiquidThreads/classes/LqtView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/classes/LqtView.php
@@ -26,6 +26,8 @@
2727 protected $threadNestingLevel = 0;
2828
2929 protected $sort_order = LQT_NEWEST_CHANGES;
 30+
 31+ static $stylesAndScriptsDone = false;
3032
3133 function __construct( &$output, &$article, &$title, &$user, &$request ) {
3234 $this->article = $article;
@@ -621,12 +623,19 @@
622624 static function addJSandCSS() {
623625 // Changed this to be static so that we can call it from
624626 // wfLqtBeforeWatchlistHook.
 627+
 628+ if ( self::$stylesAndScriptsDone ) {
 629+ return;
 630+ }
 631+
625632 global $wgOut;
626633 global $wgScriptPath, $wgStyleVersion;
627634
628635 $wgOut->addInlineScript( 'var wgLqtMessages = ' . self::exportJSLocalisation() . ';' );
629636 $wgOut->addScriptFile( "{$wgScriptPath}/extensions/LiquidThreads/lqt.js" );
630637 $wgOut->addExtensionStyle( "{$wgScriptPath}/extensions/LiquidThreads/lqt.css?{$wgStyleVersion}" );
 638+
 639+ self::$stylesAndScriptsDone = true;
631640 }
632641
633642 static function exportJSLocalisation() {
Index: trunk/extensions/LiquidThreads/classes/LqtDispatch.php
@@ -184,7 +184,7 @@
185185 $thread = Threads::withRoot( new Post( $rc->getTitle() ) );
186186 if ( !$thread ) return true;
187187
188 - LqtView::addJSandCSS(); // TODO only do this once.
 188+ LqtView::addJSandCSS();
189189 wfLoadExtensionMessages( 'LiquidThreads' );
190190
191191 if ( $rc->mAttribs['rc_type'] != RC_NEW ) {

Status & tagging log