Self-revert r110124, needs more than that to support 5.2 since $flags don't exist...
[lhc/web/wiklou.git] / includes / Setup.php
index 9a217ed..1cf803c 100644 (file)
@@ -41,6 +41,18 @@ if ( $wgArticlePath === false ) {
        }
 }
 
+if ( !empty($wgActionPaths) && !isset($wgActionPaths['view']) ) {
+       # 'view' is assumed the default action path everywhere in the code
+       # but is rarely filled in $wgActionPaths
+       $wgActionPaths['view'] = $wgArticlePath;
+}
+
+if ( !empty($wgActionPaths) && !isset($wgActionPaths['view']) ) {
+       # 'view' is assumed the default action path everywhere in the code
+       # but is rarely filled in $wgActionPaths 
+       $wgActionPaths['view'] = $wgArticlePath ;
+}
+
 if ( $wgStylePath === false ) $wgStylePath = "$wgScriptPath/skins";
 if ( $wgLocalStylePath === false ) $wgLocalStylePath = "$wgScriptPath/skins";
 if ( $wgStyleDirectory === false ) $wgStyleDirectory   = "$IP/skins";
@@ -51,8 +63,6 @@ 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";
@@ -104,6 +114,19 @@ $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
 $wgNamespaceAliases['Image'] = NS_FILE;
 $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
 
+/**
+ * Initialise $wgLockManagers to include basic FS version
+ */
+$wgLockManagers[] = array(
+       'name'          => 'fsLockManager',
+       'class'         => 'FSLockManager',
+       'lockDirectory' => "{$wgUploadDirectory}/lockdir",
+);
+$wgLockManagers[] = array(
+       'name'          => 'nullLockManager',
+       'class'         => 'NullLockManager',
+);
+
 /**
  * Initialise $wgLocalFileRepo from backwards-compatible settings
  */
@@ -153,7 +176,7 @@ if ( $wgUseSharedUploads ) {
                );
        } else {
                $wgForeignFileRepos[] = array(
-                       'class' => 'FSRepo',
+                       'class' => 'FileRepo',
                        'name' => 'shared',
                        'directory' => $wgSharedUploadDirectory,
                        'url' => $wgSharedUploadPath,
@@ -167,15 +190,38 @@ if ( $wgUseSharedUploads ) {
 }
 if ( $wgUseInstantCommons ) {
        $wgForeignFileRepos[] = array(
-               'class'                   => 'ForeignAPIRepo',
-               'name'                    => 'wikimediacommons',
-               'apibase'                 => 'http://commons.wikimedia.org/w/api.php',
-               'hashLevels'              => 2,
-               'fetchDescription'        => true,
-               'descriptionCacheExpiry'  => 43200,
-               'apiThumbCacheExpiry'     => 86400,
+               'class'                  => 'ForeignAPIRepo',
+               'name'                   => 'wikimediacommons',
+               'apibase'                => WebRequest::detectProtocol() === 'https' ?
+                       'https://commons.wikimedia.org/w/api.php' :
+                       'http://commons.wikimedia.org/w/api.php',
+               'hashLevels'             => 2,
+               'fetchDescription'       => true,
+               'descriptionCacheExpiry' => 43200,
+               'apiThumbCacheExpiry'    => 86400,
        );
 }
+/*
+ * Add on default file backend config for file repos.
+ * FileBackendGroup will handle initializing the backends.
+ */
+if ( !isset( $wgLocalFileRepo['backend'] ) ) {
+       $wgLocalFileRepo['backend'] = $wgLocalFileRepo['name'] . '-backend';
+}
+foreach ( $wgForeignFileRepos as &$repo ) {
+       if ( !isset( $repo['directory'] ) && $repo['class'] === 'ForeignAPIRepo' ) {
+               $repo['directory'] = $wgUploadDirectory; // b/c
+       }
+       if ( !isset( $repo['backend'] ) ) {
+               $repo['backend'] = $repo['name'] . '-backend';
+       }
+}
+unset( $repo ); // no global pollution; destroy reference
+
+if ( is_null( $wgEnableAutoRotation ) ) {
+       // Only enable auto-rotation when the bitmap handler can rotate
+       $wgEnableAutoRotation = BitmapHandler::canRotate();
+}
 
 if ( $wgRCFilterByAge ) {
        # # Trim down $wgRCLinkDays so that it only lists links which are valid
@@ -218,6 +264,35 @@ if ( $wgMetaNamespace === false ) {
        $wgMetaNamespace = str_replace( ' ', '_', $wgSitename );
 }
 
+/**
+ * Definitions of the NS_ constants are in Defines.php
+ * @private
+ */
+$wgCanonicalNamespaceNames = array(
+       NS_MEDIA            => 'Media',
+       NS_SPECIAL          => 'Special',
+       NS_TALK             => 'Talk',
+       NS_USER             => 'User',
+       NS_USER_TALK        => 'User_talk',
+       NS_PROJECT          => 'Project',
+       NS_PROJECT_TALK     => 'Project_talk',
+       NS_FILE             => 'File',
+       NS_FILE_TALK        => 'File_talk',
+       NS_MEDIAWIKI        => 'MediaWiki',
+       NS_MEDIAWIKI_TALK   => 'MediaWiki_talk',
+       NS_TEMPLATE         => 'Template',
+       NS_TEMPLATE_TALK    => 'Template_talk',
+       NS_HELP             => 'Help',
+       NS_HELP_TALK        => 'Help_talk',
+       NS_CATEGORY         => 'Category',
+       NS_CATEGORY_TALK    => 'Category_talk',
+);
+
+/// @todo UGLY UGLY
+if( is_array( $wgExtraNamespaces ) ) {
+       $wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
+}
+
 # These are now the same, always
 # To determine the user language, use $wgLang->getCode()
 $wgContLanguageCode = $wgLanguageCode;
@@ -234,15 +309,19 @@ if ( !$wgAllowRealName ) {
        $wgHiddenPrefs[] = 'realname';
 }
 
-if ( !$wgAllowUserSkin ) {
-       $wgHiddenPrefs[] = 'skin';
-}
-
 # Doesn't make sense to have if disabled.
 if ( !$wgEnotifMinorEdits ) {
        $wgHiddenPrefs[] = 'enotifminoredits';
 }
 
+# $wgDisabledActions is deprecated as of 1.18
+foreach( $wgDisabledActions as $action ){
+       $wgActions[$action] = false;
+}
+if( !$wgAllowPageInfo ){
+       $wgActions['info'] = false;
+}
+
 if ( !$wgHtml5Version && $wgHtml5 && $wgAllowRdfaAttributes ) {
        # see http://www.w3.org/TR/rdfa-in-html/#document-conformance
        if ( $wgMimeType == 'application/xhtml+xml' ) {
@@ -255,6 +334,10 @@ if ( !$wgHtml5Version && $wgHtml5 && $wgAllowRdfaAttributes ) {
 # Blacklisted file extensions shouldn't appear on the "allowed" list
 $wgFileExtensions = array_diff ( $wgFileExtensions, $wgFileBlacklist );
 
+if ( $wgArticleCountMethod === null ) {
+       $wgArticleCountMethod = $wgUseCommaCount ? 'comma' : 'link';
+}
+
 if ( $wgInvalidateCacheOnLocalSettingsChange ) {
        $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( "$IP/LocalSettings.php" ) ) );
 }
@@ -268,28 +351,41 @@ if ( $wgNewUserLog ) {
        $wgLogTypes[]                        = 'newusers';
        $wgLogNames['newusers']              = 'newuserlogpage';
        $wgLogHeaders['newusers']            = 'newuserlogpagetext';
-       $wgLogActions['newusers/newusers']   = 'newuserlogentry'; // For compatibility with older log entries
-       $wgLogActions['newusers/create']     = 'newuserlog-create-entry';
-       $wgLogActions['newusers/create2']    = 'newuserlog-create2-entry';
-       $wgLogActions['newusers/autocreate'] = 'newuserlog-autocreate-entry';
+       # newusers, create, create2, autocreate
+       $wgLogActionsHandlers['newusers/*']  = 'NewUsersLogFormatter';
 }
 
-if ( !class_exists( 'AutoLoader' ) ) {
-       require_once( "$IP/includes/AutoLoader.php" );
+if ( $wgCookieSecure === 'detect' ) {
+       $wgCookieSecure = ( substr( $wgServer, 0, 6 ) === 'https:' );
 }
 
-wfProfileIn( $fname . '-exception' );
-require_once( "$IP/includes/Exception.php" );
-wfInstallExceptionHandler();
-wfProfileOut( $fname . '-exception' );
+if ( $wgDebugToolbar ) {
+       MWDebug::init();
+}
+
+if ( !defined( 'MW_COMPILED' ) ) {
+       if ( !MWInit::classExists( 'AutoLoader' ) ) {
+               require_once( "$IP/includes/AutoLoader.php" );
+       }
+
+       wfProfileIn( $fname . '-exception' );
+       MWExceptionHandler::installHandler();
+       wfProfileOut( $fname . '-exception' );
+
+       wfProfileIn( $fname . '-includes' );
+       require_once( "$IP/includes/normal/UtfNormalUtil.php" );
+       require_once( "$IP/includes/GlobalFunctions.php" );
+       require_once( "$IP/includes/ProxyTools.php" );
+       require_once( "$IP/includes/ImageFunctions.php" );
+       require_once( "$IP/includes/normal/UtfNormalDefines.php" );
+       wfProfileOut( $fname . '-includes' );
+}
+
+# Now that GlobalFunctions is loaded, set the default for $wgCanonicalServer
+if ( $wgCanonicalServer === false ) {
+       $wgCanonicalServer = wfExpandUrl( $wgServer, PROTO_HTTP );
+}
 
-wfProfileIn( $fname . '-includes' );
-require_once( "$IP/includes/GlobalFunctions.php" );
-require_once( "$IP/includes/Hooks.php" );
-require_once( "$IP/includes/Namespace.php" );
-require_once( "$IP/includes/ProxyTools.php" );
-require_once( "$IP/includes/ImageFunctions.php" );
-wfProfileOut( $fname . '-includes' );
 wfProfileIn( $fname . '-misc1' );
 
 # Raise the memory limit if it's too low
@@ -300,18 +396,27 @@ wfMemoryLimit();
  * that happens whenever you use a date function without the timezone being
  * explicitly set. Inspired by phpMyAdmin's treatment of the problem.
  */
-wfSuppressWarnings();
-date_default_timezone_set( date_default_timezone_get() );
-wfRestoreWarnings();
+if ( is_null( $wgLocaltimezone) ) {
+       wfSuppressWarnings();
+       $wgLocaltimezone = date_default_timezone_get();
+       wfRestoreWarnings();
+}
 
-# Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
-$wgRequest = new WebRequest;
+date_default_timezone_set( $wgLocaltimezone );
+if( is_null( $wgLocalTZoffset ) ) {
+       $wgLocalTZoffset = date( 'Z' ) / 60;
+}
 
 # Useful debug output
 global $wgCommandLineMode;
 if ( $wgCommandLineMode ) {
+       $wgRequest = new FauxRequest( array() );
+
        wfDebug( "\n\nStart command line script $self\n" );
 } else {
+       # Can't stub this one, it sets up $_GET and $_REQUEST in its constructor
+       $wgRequest = new WebRequest;
+
        $debug = "Start request\n\n{$_SERVER['REQUEST_METHOD']} {$wgRequest->getRequestURL()}";
 
        if ( $wgDebugPrintHttpHeaders ) {
@@ -322,6 +427,7 @@ if ( $wgCommandLineMode ) {
                }
        }
        wfDebug( "$debug\n" );
+       MWDebug::processRequest( $wgRequest );
 }
 
 wfProfileOut( $fname . '-misc1' );
@@ -361,13 +467,27 @@ if ( !defined( 'MW_NO_SESSION' ) && !$wgCommandLineMode ) {
 wfProfileOut( $fname . '-session' );
 wfProfileIn( $fname . '-globals' );
 
-$wgContLang = new StubContLang;
+$wgContLang = Language::factory( $wgLanguageCode );
+$wgContLang->initEncoding();
+$wgContLang->initContLang();
 
 // Now that variant lists may be available...
 $wgRequest->interpolateTitle();
-$wgUser = $wgCommandLineMode ? new User : User::newFromSession();
+$wgUser = RequestContext::getMain()->getUser(); # BackCompat
+
+/**
+ * @var Language
+ */
 $wgLang = new StubUserLang;
-$wgOut = new StubObject( 'wgOut', 'OutputPage' );
+
+/**
+ * @var OutputPage
+ */
+$wgOut = RequestContext::getMain()->getOutput(); # BackCompat
+
+/**
+ * @var Parser
+ */
 $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
 
 if ( !is_object( $wgAuth ) ) {
@@ -377,20 +497,12 @@ if ( !is_object( $wgAuth ) ) {
 
 # Placeholders in case of DB error
 $wgTitle = null;
-$wgArticle = null;
 
 $wgDeferredUpdateList = array();
 
 wfProfileOut( $fname . '-globals' );
 wfProfileIn( $fname . '-extensions' );
 
-# Skin setup functions
-# Entries can be added to this variable during the inclusion
-# of the extension file. Skins can then perform any necessary initialisation.
-foreach ( $wgSkinExtensionFunctions as $func ) {
-       call_user_func( $func );
-}
-
 # Extension setup functions for extensions other than skins
 # Entries should be added to this variable during the inclusion
 # of the extension file. This allows the extension to perform
@@ -413,13 +525,8 @@ foreach ( $wgExtensionFunctions as $func ) {
        wfProfileOut( $profName );
 }
 
-// For compatibility
-wfRunHooks( 'LogPageValidTypes', array( &$wgLogTypes ) );
-wfRunHooks( 'LogPageLogName', array( &$wgLogNames ) );
-wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) );
-wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) );
-
 wfDebug( "Fully initialised\n" );
 $wgFullyInitialised = true;
+
 wfProfileOut( $fname . '-extensions' );
 wfProfileOut( $fname );