* (bug 1184) expiry time of indefinite blocks shown as the current time
[lhc/web/wiklou.git] / includes / Setup.php
index 276b023..05e968f 100644 (file)
@@ -16,7 +16,7 @@ if( defined( 'MEDIAWIKI' ) ) {
 # setting up a few globals.
 #
 
-global $wgProfiling, $wgProfileSampleRate, $wgIP, $wgUseSquid;
+global $wgProfiling, $wgProfileSampleRate, $wgIP, $wgUseSquid, $IP;
 
 if( !isset( $wgProfiling ) )
        $wgProfiling = false;
@@ -58,6 +58,7 @@ global $wgUseDynamicDates;
 wfProfileIn( $fname.'-includes' );
 
 require_once( 'GlobalFunctions.php' );
+require_once( 'Hooks.php' );
 require_once( 'Namespace.php' );
 require_once( 'RecentChange.php' ); 
 require_once( 'User.php' );
@@ -71,14 +72,14 @@ require_once( 'Block.php' );
 require_once( 'MessageCache.php' );
 require_once( 'BlockCache.php' );
 require_once( 'Parser.php' );
+require_once( 'ParserXML.php' );
 require_once( 'ParserCache.php' );
 require_once( 'WebRequest.php' );
 require_once( 'LoadBalancer.php' );
+require_once( 'HistoryBlob.php' );
 
 $wgRequest = new WebRequest();
 
-
-
 wfProfileOut( $fname.'-includes' );
 wfProfileIn( $fname.'-misc1' );
 global $wgUser, $wgLang, $wgContLang, $wgOut, $wgTitle;
@@ -181,7 +182,7 @@ if( $wgUseMemCached ) {
 wfProfileOut( $fname.'-memcached' );
 wfProfileIn( $fname.'-SetupSession' );
 
-if( !$wgCommandLineMode && ( isset( $_COOKIE[ini_get('session.name')] ) || isset( $_COOKIE[$wgDBname.'Password'] ) ) ) {
+if( !$wgCommandLineMode && ( isset( $_COOKIE[ini_get('session.name')] ) || isset( $_COOKIE[$wgDBname.'Token'] ) ) ) {
        User::SetupSession();
        $wgSessionStarted = true;
 } else {
@@ -206,6 +207,11 @@ $wgLoadBalancer = LoadBalancer::newFromParams( $wgDBservers );
 $wgLoadBalancer->loadMasterPos();
 
 wfProfileOut( $fname.'-database' );
+wfProfileIn( $fname.'-language1' );
+
+require_once( "$IP/languages/Language.php" );
+
+wfProfileOut( $fname.'-language1' );
 wfProfileIn( $fname.'-User' );
 
 # Skin setup functions
@@ -215,6 +221,11 @@ foreach ( $wgSkinExtensionFunctions as $func ) {
        $func();
 }
 
+if( !is_object( $wgAuth ) ) {
+       require_once( 'AuthPlugin.php' );
+       $wgAuth = new AuthPlugin();
+}
+
 if( $wgCommandLineMode ) {
        # Used for some maintenance scripts; user session cookies can screw things up
        # when the database is in an in-between state.
@@ -224,43 +235,41 @@ if( $wgCommandLineMode ) {
 }
 
 wfProfileOut( $fname.'-User' );
-wfProfileIn( $fname.'-language' );
-
-function setupLangObj(&$langclass, $langcode) {
-       global $wgUseLatin1;
+wfProfileIn( $fname.'-language2' );
 
+function setupLangObj(&$langclass) {
+       global $wgUseLatin1, $IP;
 
        if( ! class_exists( $langclass ) ) {
-               # Default to English/UTF-8
-               require_once( 'languages/LanguageUtf8.php' );
-               $langclass = 'LanguageUtf8';
+               # Default to English/UTF-8, or for non-UTF-8, to latin-1
+               $baseclass = 'LanguageUtf8';
+               if( $wgUseLatin1 )
+                       $baseclass = 'LanguageLatin1';
+               require_once( "$IP/languages/$baseclass.php" );
+               $lc = strtolower(substr($langclass, 8));
+               $snip = "
+                       class $langclass extends $baseclass {
+                               function getVariants() {
+                                       return array(\"$lc\");
+                               }
+
+                       }";
+
+               eval($snip);
        }
 
        $lang = new $langclass();
-       if ( !is_object($lang) ) {
-               print "No language class ($wgLang)\N";
-       }
 
-       if( $wgUseLatin1 ) {
-               # For non-UTF-8 latin-1 downconversion
-               require_once( 'languages/LanguageLatin1.php' );
-               $xxx = new LanguageLatin1( $lang );
-               unset( $lang );
-               $lang = $xxx;
-       }
        return $lang;
 }
 
-require_once( 'languages/Language.php' );
-
 # $wgLanguageCode may be changed later to fit with user preference.
 # The content language will remain fixed as per the configuration,
 # so let's keep it.
 $wgContLanguageCode = $wgLanguageCode;
 $wgContLangClass = 'Language' . str_replace( '-', '_', ucfirst( $wgContLanguageCode ) );
 
-$wgContLang = setupLangObj( $wgContLangClass, $wgContLangClass );
-$n = get_class($wgContLang);
+$wgContLang = setupLangObj( $wgContLangClass );
 
 // set default user option from content language
 if( !$wgUser->mDataLoaded ) {
@@ -269,16 +278,23 @@ if( !$wgUser->mDataLoaded ) {
 
 // wgLanguageCode now specifically means the UI language
 $wgLanguageCode = $wgUser->getOption('language');
+if( empty( $wgLanguageCode ) ) {
+       # Quick hack for upgrades where this will be blank,
+       # and it's not handled right. Set to default.
+       $wgLanguageCode = $wgContLanguageCode;
+}
 
 $wgLangClass = 'Language'. str_replace( '-', '_', ucfirst( $wgLanguageCode ) );
 
 if( $wgLangClass == $wgContLangClass ) {
        $wgLang = &$wgContLang;
 } else {
-       require_once("languages/$wgLangClass.php");
-       $wgLang = setupLangObj( $wgLangClass, $wgLanguageCode );
-}
+       wfSuppressWarnings();
+       include_once("$IP/languages/$wgLangClass.php");
+       wfRestoreWarnings();
 
+       $wgLang = setupLangObj( $wgLangClass );
+}
 
 wfProfileOut( $fname.'-language' );
 wfProfileIn( $fname.'-MessageCache' );
@@ -336,16 +352,37 @@ $wgDeferredUpdateList = array();
 $wgLinkCache = new LinkCache();
 $wgMagicWords = array();
 $wgMwRedir =& MagicWord::get( MAG_REDIRECT );
-$wgParserCache = new ParserCache();
-$wgParser = new Parser();
+$wgParserCache = new ParserCache( $messageMemc );
+
+if ( $wgUseXMLparser ) $wgParser = new ParserXML();
+else $wgParser = new Parser();
 $wgOut->setParserOptions( ParserOptions::newFromUser( $wgUser ) );
 $wgMsgParserOptions = ParserOptions::newFromUser($wgUser);
 wfSeedRandom();
 
 # Placeholders in case of DB error
-$wgTitle = Title::newFromText( wfMsgForContent( 'badtitle' ) );
+$wgTitle = Title::makeTitle( NS_SPECIAL, 'Error' );
 $wgArticle = new Article($wgTitle);
 
+# Site notice
+
+$notice = wfMsg( 'sitenotice' );
+if($notice == '<sitenotice>') $notice = '';
+# Allow individual wikis to turn it off
+if ( $notice == '-' ) {
+       $wgSiteNotice = '';
+} else {
+       # if($wgSiteNotice) $notice .= $wgSiteNotice;
+       if ($notice == '') {
+               $notice = $wgSiteNotice;
+       }
+       if($notice != '-' && $notice != '') {
+               $specialparser = new Parser();
+               $parserOutput = $specialparser->parse( $notice, $wgTitle, $wgOut->mParserOptions, false );
+               $wgSiteNotice = $parserOutput->getText();
+       }
+}
+
 wfProfileOut( $fname.'-misc2' );
 wfProfileIn( $fname.'-extensions' );