* Introduced LBFactory -- an abstract class for configuring database load balancers...
[lhc/web/wiklou.git] / includes / Setup.php
index 68a4802..4413741 100644 (file)
@@ -1,7 +1,6 @@
 <?php
 /**
  * Include most things that's need to customize the site
- * @package MediaWiki
  */
 
 /**
@@ -28,6 +27,94 @@ if ( !isset( $wgVersion ) ) {
        die( 1 );
 }
 
+// Set various default paths sensibly...
+if( $wgScript === false ) $wgScript = "$wgScriptPath/index$wgScriptExtension";
+if( $wgRedirectScript === false ) $wgRedirectScript = "$wgScriptPath/redirect$wgScriptExtension";
+
+if( $wgArticlePath === false ) {
+       if( $wgUsePathInfo ) {
+               $wgArticlePath      = "$wgScript/$1";
+       } else {
+               $wgArticlePath      = "$wgScript?title=$1";
+       }
+}
+
+if( $wgStylePath === false ) $wgStylePath = "$wgScriptPath/skins";
+if( $wgStyleDirectory === false) $wgStyleDirectory   = "$IP/skins";
+
+if( $wgLogo === false ) $wgLogo = "$wgStylePath/common/images/wiki.png";
+
+if( $wgUploadPath === false ) $wgUploadPath = "$wgScriptPath/images";
+if( $wgUploadDirectory === false ) $wgUploadDirectory = "$IP/images";
+
+if( $wgMathPath === false ) $wgMathPath = "{$wgUploadPath}/math";
+if( $wgMathDirectory === false ) $wgMathDirectory = "{$wgUploadDirectory}/math";
+if( $wgTmpDirectory === false ) $wgTmpDirectory = "{$wgUploadDirectory}/tmp";
+
+if( $wgReadOnlyFile === false ) $wgReadOnlyFile = "{$wgUploadDirectory}/lock_yBgMBwiR";
+if( $wgFileCacheDirectory === false ) $wgFileCacheDirectory = "{$wgUploadDirectory}/cache";
+
+if ( empty( $wgFileStore['deleted']['directory'] ) ) {
+       $wgFileStore['deleted']['directory'] = "{$wgUploadDirectory}/deleted";
+}
+
+
+/**
+ * Initialise $wgLocalFileRepo from backwards-compatible settings
+ */
+if ( !$wgLocalFileRepo ) {
+       $wgLocalFileRepo = array( 
+               'class' => 'LocalRepo',
+               'name' => 'local',
+               'directory' => $wgUploadDirectory,
+               'url' => $wgUploadBaseUrl ? $wgUploadBaseUrl . $wgUploadPath : $wgUploadPath,
+               'hashLevels' => $wgHashedUploadDirectory ? 2 : 0,
+               'thumbScriptUrl' => $wgThumbnailScriptPath,
+               'transformVia404' => !$wgGenerateThumbnailOnParse,
+               'initialCapital' => $wgCapitalLinks,
+               'deletedDir' => $wgFileStore['deleted']['directory'],
+               'deletedHashLevels' => $wgFileStore['deleted']['hash']
+       );
+}
+/**
+ * Initialise shared repo from backwards-compatible settings
+ */
+if ( $wgUseSharedUploads ) {
+       if ( $wgSharedUploadDBname ) {
+               $wgForeignFileRepos[] = array(
+                       'class' => 'ForeignDBRepo',
+                       'name' => 'shared',
+                       'directory' => $wgSharedUploadDirectory,
+                       'url' => $wgSharedUploadPath,
+                       'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
+                       'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
+                       'transformVia404' => !$wgGenerateThumbnailOnParse,
+                       'dbType' => $wgDBtype,
+                       'dbServer' => $wgDBserver,
+                       'dbUser' => $wgDBuser,
+                       'dbPassword' => $wgDBpassword,
+                       'dbName' => $wgSharedUploadDBname,
+                       'dbFlags' => ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT,
+                       'tablePrefix' => $wgSharedUploadDBprefix,
+                       'hasSharedCache' => $wgCacheSharedUploads,
+                       'descBaseUrl' => $wgRepositoryBaseUrl,
+                       'fetchDescription' => $wgFetchCommonsDescriptions,
+               );
+       } else {
+               $wgForeignFileRepos[] = array( 
+                       'class' => 'FSRepo',
+                       'name' => 'shared',
+                       'directory' => $wgSharedUploadDirectory,
+                       'url' => $wgSharedUploadPath,
+                       'hashLevels' => $wgHashedSharedUploadDirectory ? 2 : 0,
+                       'thumbScriptUrl' => $wgSharedThumbnailScriptPath,
+                       'transformVia404' => !$wgGenerateThumbnailOnParse,
+                       'descBaseUrl' => $wgRepositoryBaseUrl,
+                       'fetchDescription' => $wgFetchCommonsDescriptions,
+               );
+       }
+}
+
 require_once( "$IP/includes/AutoLoader.php" );
 
 wfProfileIn( $fname.'-exception' );
@@ -107,13 +194,14 @@ if ( $wgDBprefix ) {
 } else {
        $wgCookiePrefix = $wgDBname;
 }
+$wgCookiePrefix = strtr($wgCookiePrefix, "=,; +.\"'\\[", "__________");
 
 # If session.auto_start is there, we can't touch session name
 #
-if( !ini_get( 'session.auto_start' ) )
+if( !wfIniGetBool( 'session.auto_start' ) )
        session_name( $wgSessionName ? $wgSessionName : $wgCookiePrefix . '_session' );
 
-if( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
+if( !$wgCommandLineMode && ( $wgRequest->checkSessionCookie() || isset( $_COOKIE[$wgCookiePrefix.'Token'] ) ) ) {
        wfIncrStats( 'request_with_session' );
        wfSetupSession();
        $wgSessionStarted = true;
@@ -125,27 +213,18 @@ if( !$wgCommandLineMode && ( isset( $_COOKIE[session_name()] ) || isset( $_COOKI
 wfProfileOut( $fname.'-SetupSession' );
 wfProfileIn( $fname.'-globals' );
 
-if ( !$wgDBservers ) {
-       $wgDBservers = array(array(
-               'host' => $wgDBserver,
-               'user' => $wgDBuser,
-               'password' => $wgDBpassword,
-               'dbname' => $wgDBname,
-               'type' => $wgDBtype,
-               'load' => 1,
-               'flags' => ($wgDebugDumpSql ? DBO_DEBUG : 0) | DBO_DEFAULT
-       ));
-}
-
-$wgLoadBalancer = new StubObject( 'wgLoadBalancer', 'LoadBalancer', 
-       array( $wgDBservers, false, $wgMasterWaitTimeout, true ) );
 $wgContLang = new StubContLang;
+
+// Now that variant lists may be available...
+$wgRequest->interpolateTitle();
+
 $wgUser = new StubUser;
 $wgLang = new StubUserLang;
 $wgOut = new StubObject( 'wgOut', 'OutputPage' );
-$wgParser = new StubObject( 'wgParser', 'Parser' );
+$wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
+
 $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache', 
-       array( $parserMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, $wgDBname) );
+       array( $parserMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, wfWikiID() ) );
 
 wfProfileOut( $fname.'-globals' );
 wfProfileIn( $fname.'-User' );
@@ -160,7 +239,9 @@ foreach ( $wgSkinExtensionFunctions as $func ) {
 
 if( !is_object( $wgAuth ) ) {
        $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' );
+       wfRunHooks( 'AuthPluginSetup', array( &$wgAuth ) );
 }
+
 wfProfileOut( $fname.'-User' );
 
 wfProfileIn( $fname.'-misc2' );
@@ -168,6 +249,12 @@ wfProfileIn( $fname.'-misc2' );
 $wgDeferredUpdateList = array();
 $wgPostCommitUpdateList = array();
 
+if ( $wgAjaxSearch ) $wgAjaxExportList[] = 'wfSajaxSearch';
+if ( $wgAjaxWatch ) $wgAjaxExportList[] = 'wfAjaxWatch';
+if ( $wgAjaxUploadDestCheck ) $wgAjaxExportList[] = 'UploadForm::ajaxGetExistsWarning';
+if( $wgAjaxLicensePreview )
+       $wgAjaxExportList[] = 'UploadForm::ajaxGetLicensePreview';
+
 wfSeedRandom();
 
 # Placeholders in case of DB error
@@ -182,7 +269,10 @@ wfProfileIn( $fname.'-extensions' );
 # of the extension file. This allows the extension to perform
 # any necessary initialisation in the fully initialised environment
 foreach ( $wgExtensionFunctions as $func ) {
+       $profName = $fname.'-extensions-'.strval( $func );
+       wfProfileIn( $profName );
        call_user_func( $func );
+       wfProfileOut( $profName );
 }
 
 // For compatibility
@@ -197,4 +287,4 @@ $wgFullyInitialised = true;
 wfProfileOut( $fname.'-extensions' );
 wfProfileOut( $fname );
 
-?>
+