fix some doxygen warnings
[lhc/web/wiklou.git] / includes / Setup.php
index 92e310b..b03e188 100644 (file)
@@ -58,6 +58,14 @@ if ( empty( $wgFileStore['deleted']['directory'] ) ) {
        $wgFileStore['deleted']['directory'] = "{$wgUploadDirectory}/deleted";
 }
 
+/**
+ * Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a 
+ * sysadmin to set $wgNamespaceProtection incorrectly and leave the wiki insecure. 
+ *
+ * Note that this is the definition of editinterface and it can be granted to 
+ * all users if desired.
+ */
+$wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
 
 /**
  * Initialise $wgLocalFileRepo from backwards-compatible settings
@@ -115,7 +123,16 @@ if ( $wgUseSharedUploads ) {
        }
 }
 
-require_once( "$IP/includes/AutoLoader.php" );
+/**
+ * Workaround for http://bugs.php.net/bug.php?id=45132
+ * escapeshellarg() destroys non-ASCII characters if LANG is not a UTF-8 locale
+ */
+putenv( 'LC_CTYPE=en_US.UTF-8' );
+setlocale( LC_CTYPE, 'en_US.UTF-8' );
+
+if ( !class_exists( 'AutoLoader' ) ) {
+       require_once( "$IP/includes/AutoLoader.php" );
+}
 
 wfProfileIn( $fname.'-exception' );
 require_once( "$IP/includes/Exception.php" );
@@ -159,6 +176,19 @@ if ( $wgCommandLineMode ) {
        wfDebug( $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . "\n" );
 }
 
+if( $wgRCFilterByAge ) {
+       ## Trim down $wgRCLinkDays so that it only lists links which are valid
+       ## as determined by $wgRCMaxAge.
+       ## Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
+       sort($wgRCLinkDays);
+       for( $i = 0; $i < count($wgRCLinkDays); $i++ ) {
+               if( $wgRCLinkDays[$i] >= $wgRCMaxAge / ( 3600 * 24 ) ) {
+                       $wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i+1, false );
+                       break;
+               }
+       }
+}
+
 if ( $wgSkipSkin ) {
        $wgSkipSkins[] = $wgSkipSkin;
 }
@@ -181,8 +211,8 @@ $messageMemc =& wfGetMessageCacheStorage();
 $parserMemc =& wfGetParserCacheStorage();
 
 wfDebug( 'Main cache: ' . get_class( $wgMemc ) .
-       "\nMessage cache: " . get_class( $messageMemc ) .
-          "\nParser cache: " . get_class( $parserMemc ) . "\n" );
+       "\nMessage cache: " . get_class( $messageMemc ) .
+       "\nParser cache: " . get_class( $parserMemc ) . "\n" );
 
 wfProfileOut( $fname.'-memcached' );
 wfProfileIn( $fname.'-SetupSession' );
@@ -190,12 +220,16 @@ wfProfileIn( $fname.'-SetupSession' );
 # Set default shared prefix
 if( $wgSharedPrefix === false ) $wgSharedPrefix = $wgDBprefix;
 
-if ( $wgDBprefix ) {
-       $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
-} elseif ( $wgSharedDB ) {
-       $wgCookiePrefix = $wgSharedDB;
-} else {
-       $wgCookiePrefix = $wgDBname;
+if( !$wgCookiePrefix ) {
+       if ( in_array('user', $wgSharedTables) && $wgSharedDB && $wgSharedPrefix ) {
+               $wgCookiePrefix = $wgSharedDB . '_' . $wgSharedPrefix;
+       } elseif ( in_array('user', $wgSharedTables) && $wgSharedDB ) {
+               $wgCookiePrefix = $wgSharedDB;
+       } elseif ( $wgDBprefix ) {
+               $wgCookiePrefix = $wgDBname . '_' . $wgDBprefix;
+       } else {
+               $wgCookiePrefix = $wgDBname;
+       }
 }
 $wgCookiePrefix = strtr($wgCookiePrefix, "=,; +.\"'\\[", "__________");
 
@@ -227,7 +261,7 @@ $wgOut = new StubObject( 'wgOut', 'OutputPage' );
 $wgParser = new StubObject( 'wgParser', $wgParserConf['class'], array( $wgParserConf ) );
 
 $wgMessageCache = new StubObject( 'wgMessageCache', 'MessageCache',
-       array( $parserMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, wfWikiID() ) );
+       array( $messageMemc, $wgUseDatabaseMessages, $wgMsgCacheExpiry, wfWikiID() ) );
 
 wfProfileOut( $fname.'-globals' );
 wfProfileIn( $fname.'-User' );
@@ -252,14 +286,11 @@ 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
 $wgTitle = null;
 $wgArticle = null;
@@ -284,6 +315,16 @@ wfRunHooks( 'LogPageLogName', array( &$wgLogNames ) );
 wfRunHooks( 'LogPageLogHeader', array( &$wgLogHeaders ) );
 wfRunHooks( 'LogPageActionText', array( &$wgLogActions ) );
 
+if( !empty($wgNewUserLog) ) {
+       # Add a new log type
+       $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';
+}
 
 wfDebug( "Fully initialised\n" );
 $wgFullyInitialised = true;