* Fix explicit s-maxage=0 on raw pages; should help with proxy issues in
[lhc/web/wiklou.git] / includes / Skin.php
index eb73b38..c0b7ba1 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 if ( ! defined( 'MEDIAWIKI' ) )
-       die();
+       die( -1 );
 
 /**
  *
@@ -21,7 +21,8 @@ $skinDir = dir($IP.'/skins');
 
 # while code from www.php.net
 while (false !== ($file = $skinDir->read())) {
-       if(preg_match('/^([^.].*)\.php$/',$file, $matches)) {
+       // Skip non-PHP files, hidden files, and '.dep' includes
+       if(preg_match('/^([^.]*)\.php$/',$file, $matches)) {
                $aSkin = $matches[1];
                $wgValidSkinNames[strtolower($aSkin)] = $aSkin;
        }
@@ -30,8 +31,7 @@ $skinDir->close();
 unset($matches);
 
 /**
- * The main skin class that provide methods and properties for all other skins
- * including PHPTal skins.
+ * The main skin class that provide methods and properties for all other skins.
  * This base class is also the "Standard" skin.
  * @package MediaWiki
  */
@@ -113,8 +113,11 @@ class Skin extends Linker {
 
                global $IP;
 
-               # Grab the skin class and initialise it. Each skin checks for PHPTal
-               # and will not load if it's not enabled.
+               # Grab the skin class and initialise it.
+               wfSuppressWarnings();
+               // Preload base classes to work around APC/PHP5 bug
+               include_once( $IP.'/skins/'.$skinName.'.deps.php' );
+               wfRestoreWarnings();
                require_once( $IP.'/skins/'.$skinName.'.php' );
 
                # Check if we got if not failback to default skin
@@ -151,10 +154,14 @@ class Skin extends Linker {
        }
 
        function initPage( &$out ) {
+               global $wgFavicon;
+
                $fname = 'Skin::initPage';
                wfProfileIn( $fname );
 
-               $out->addLink( array( 'rel' => 'shortcut icon', 'href' => '/favicon.ico' ) );
+               if( false !== $wgFavicon ) {
+                       $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) );
+               }
 
                $this->addMetadataLinks($out);
 
@@ -266,7 +273,7 @@ class Skin extends Linker {
                        $wgRequest->getVal( 'wpEditToken' ) );
        }
 
-       # get the user/site-specific stylesheet, SkinPHPTal called from RawPage.php (settings are cached that way)
+       # get the user/site-specific stylesheet, SkinTemplate loads via RawPage.php (settings are cached that way)
        function getUserStylesheet() {
                global $wgOut, $wgStylePath, $wgRequest, $wgContLang, $wgSquidMaxage;
                $sheet = $this->getStylesheet();
@@ -1319,7 +1326,7 @@ END;
                        wfMsg( 'postcomment' ), 'action=edit&section=new' );
        }
 
-       /* these are used extensively in SkinPHPTal, but also some other places */
+       /* these are used extensively in SkinTemplate, but also some other places */
        /*static*/ function makeSpecialUrl( $name, $urlaction='' ) {
                $title = Title::makeTitle( NS_SPECIAL, $name );
                return $title->getLocalURL( $urlaction );
@@ -1394,14 +1401,23 @@ END;
         */
        function buildSidebar() {
                global $wgTitle, $action, $wgDBname, $parserMemc;
+               global $wgLanguageCode, $wgContLanguageCode;
 
                $fname = 'SkinTemplate::buildSidebar';
 
                wfProfileIn( $fname );
-               $cachedsidebar=$parserMemc->get("{$wgDBname}:sidebar");
-               if ($cachedsidebar!="") {
-                       wfProfileOut($fname);
-                       return $cachedsidebar;
+
+               if ($wgLanguageCode == $wgContLanguageCode)
+                       $cacheSidebar = true;
+               else
+                       $cacheSidebar = false;
+               
+               if ($cacheSidebar) {
+                       $cachedsidebar=$parserMemc->get("{$wgDBname}:sidebar");
+                       if ($cachedsidebar!="") {
+                               wfProfileOut($fname);
+                               return $cachedsidebar;
+                       }
                }
 
                $bar = array();
@@ -1432,8 +1448,8 @@ END;
                                } else { continue; }
                        }
                }
-
-               $cachednotice=$parserMemc->set("{$wgDBname}:sidebar",$bar,86400);
+               if ($cacheSidebar)
+                       $cachednotice=$parserMemc->set("{$wgDBname}:sidebar",$bar,86400);
                wfProfileOut( $fname );
                return $bar;
        }