Remove some of the rubbish that has been accumulating in the default LocalSettings...
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 6 Dec 2010 15:00:56 +0000 (15:00 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 6 Dec 2010 15:00:56 +0000 (15:00 +0000)
* Don't set $IP. The entry point already sets it, so there's no point. Users can still set it if they can figure out a way to do it without breaking things.
* Don't include DefaultSettings.php. Doing that is code, not configuration, and it can easily be done in WebStart/Maintenance. Some non-standard entry points in extensions may be broken by this. That's their fault for being non-standard. Backwards compatibility is preserved thanks to require_once().
* Introduce $wgInvalidateCacheOnLocalSettingsChange, which when set, causes $wgCacheEpoch to be updated in the way that it previously was in the default LocalSettings.php.
* Don't set $wgLocalInterwiki to some nonsense value (possibly including spaces and punctuation in the new installer). It should be only for actual interwiki prefixes. Since most wikis don't have them, I set this to false by default and adjusted the referring code to accept this.
* Removed the guard for web invocation with $wgCommandLineMode set. This ancient code is redundant with modern protections in doMaintenance.php.
* In DefaultSettings.php, fixed fold terminator placement near $wgLoadScript
* Add a web entry point guard. That's one piece of code which really is necessary.

RELEASE-NOTES
includes/DefaultSettings.php
includes/RecentChange.php
includes/Setup.php
includes/Title.php
includes/WebStart.php
includes/installer/LocalSettingsGenerator.php
maintenance/doMaintenance.php

index 2ff7a0b..2fa6d15 100644 (file)
@@ -91,6 +91,11 @@ LocalSettings.php. The specific bugs are listed below in the general notes.
   the footers of skins.
 * $wgFileCacheDepth can be used to set the depth of the subdirectory hierarchy
   used for the file cache. Default value is 2, which matches former behavior 
+* It's no longer necessary for LocalSettings.php to include DefaultSettings.php.
+* It's no longer necessary to set $wgCacheEpoch to the file modification time
+  of LocalSettings.php, in LocalSettings.php itself. Instead, this is done 
+  automatically if $wgInvalidateCacheOnLocalSettingsChange is true (which is 
+  the default). 
 
 === New features in 1.17 ===
 * (bug 10183) Users can now add personal styles and scripts to all skins via
index 33a6101..7d3588e 100644 (file)
@@ -26,7 +26,6 @@ if( !defined( 'MEDIAWIKI' ) ) {
        die( 1 );
 }
 
-
 # Create a site configuration object. Not used for much in a default install
 if ( !defined( 'MW_PHP4' ) ) {
        require_once( "$IP/includes/SiteConfiguration.php" );
@@ -140,7 +139,6 @@ $wgScript           = false;
  * Defaults to "{$wgScriptPath}/redirect{$wgScriptExtension}".
  */
 $wgRedirectScript   = false; ///< defaults to
-/**@}*/
 
 /**
  * The URL path to load.php.
@@ -149,6 +147,8 @@ $wgRedirectScript   = false; ///< defaults to
  */
 $wgLoadScript           = false;
 
+/**@}*/
+
 /************************************************************************//**
  * @name   URLs and file paths
  *
@@ -1665,6 +1665,17 @@ $wgUseETag = false;
  */
 $wgClockSkewFudge = 5;
 
+/**
+ * Invalidate various caches when LocalSettings.php changes. This is equivalent
+ * to setting $wgCacheEpoch to the modification time of LocalSettings.php, as
+ * was previously done in the default LocalSettings.php file.
+ *
+ * On high-traffic wikis, this should be set to false, to avoid the need to 
+ * check the file modification time, and to avoid the performance impact of
+ * unnecessary cache invalidations. 
+ */
+$wgInvalidateCacheOnLocalSettingsChange = true;
+
 /** @} */ # end of cache settings
 
 /************************************************************************//**
@@ -2486,8 +2497,15 @@ $wgNamespaceAliases = array();
  */
 $wgLegalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
 
-$wgLocalInterwiki   = 'w';
-$wgInterwikiExpiry = 10800; # Expiry time for cache of interwiki table
+/**
+ * The interwiki prefix of the current wiki, or false if it doesn't have one.
+ */
+$wgLocalInterwiki   = false;
+
+/**
+ * Expiry time for cache of interwiki table
+ */
+$wgInterwikiExpiry = 10800;
 
 /** Interwiki caching settings.
        $wgInterwikiCache specifies path to constant database file
index bf8379c..803420f 100644 (file)
@@ -674,7 +674,7 @@ class RecentChange {
                        $flag .= ($rc_new ? "N" : "") . ($rc_minor ? "M" : "") . ($rc_bot ? "B" : "");
                }
 
-               if ( $wgRC2UDPInterwikiPrefix === true ) {
+               if ( $wgRC2UDPInterwikiPrefix === true && $wgLocalInterwiki !== false ) {
                        $prefix = $wgLocalInterwiki;
                } elseif ( $wgRC2UDPInterwikiPrefix ) {
                        $prefix = $wgRC2UDPInterwikiPrefix;
index b937c0e..fbaac94 100644 (file)
@@ -289,6 +289,9 @@ if ( !$wgHtml5Version && $wgHtml5 && $wgAllowRdfaAttributes ) {
        else $wgHtml5Version = 'HTML+RDFa 1.0';
 }
 
+if ( $wgInvalidateCacheOnLocalSettingsChange ) {
+       $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( "$IP/LocalSettings.php" ) ) );
+}
 
 wfProfileOut( $fname.'-misc1' );
 wfProfileIn( $fname.'-memcached' );
index 599b808..21028ea 100644 (file)
@@ -2645,7 +2645,9 @@ class Title {
                                        $this->mInterwiki = $wgContLang->lc( $p );
 
                                        # Redundant interwiki prefix to the local wiki
-                                       if ( 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) ) {
+                                       if ( $wgLocalInterwiki !== false
+                                               && 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) ) 
+                                       {
                                                if ( $dbkey == '' ) {
                                                        # Can't have an empty self-link
                                                        return false;
index 428b4ff..f05d563 100644 (file)
@@ -91,11 +91,11 @@ if ( !function_exists( 'version_compare' )
 
 # Start the autoloader, so that extensions can derive classes from core files
 require_once( "$IP/includes/AutoLoader.php" );
+# Load default settings
+require_once( "$IP/includes/DefaultSettings.php" );
 
 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
        # Use a callback function to configure MediaWiki
-       require_once( "$IP/includes/DefaultSettings.php" );
-
        $callback = MW_CONFIG_CALLBACK;
        # PHP 5.1 doesn't support "class::method" for call_user_func, so split it
        if ( strpos( $callback, '::' ) !== false ) {
@@ -110,7 +110,6 @@ if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
        # the wiki installer needs to be launched or the generated file moved from
        # ./config/ to ./
        if( !file_exists( MW_CONFIG_FILE ) ) {
-               require_once( "$IP/includes/DefaultSettings.php" ); # used for printing the version
                require_once( "$IP/includes/templates/NoLocalSettings.php" );
                die();
        }
index e3eb957..b7a8d77 100644 (file)
@@ -197,21 +197,11 @@ class LocalSettingsGenerator {
 # Further documentation for configuration settings may be found at:
 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
 
-# If you customize your file layout, set \$IP to the directory that contains
-# the other MediaWiki files. It will be used as a base to locate files.
-if( defined( 'MW_INSTALL_PATH' ) ) {
-       \$IP = MW_INSTALL_PATH;
-} else {
-       \$IP = dirname( __FILE__ );
+# Protect against web entry
+if ( !defined( 'MEDIAWIKI' ) ) {
+       exit;
 }
 
-require_once( \"\$IP/includes/DefaultSettings.php\" );
-
-if ( \$wgCommandLineMode ) {
-       if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
-               die( \"This script must be run from the command line\\n\" );
-       }
-}
 ## Uncomment this to disable output compression
 # \$wgDisableOutputCompression = true;
 
@@ -285,8 +275,6 @@ if ( \$wgCommandLineMode ) {
 ## be publically accessible from the web.
 #\$wgCacheDirectory = \"\$IP/cache\";
 
-\$wgLocalInterwiki   = strtolower( \$wgSitename );
-
 # Site language code, should be one of ./languages/Language(.*).php
 \$wgLanguageCode = \"{$this->values['wgLanguageCode']}\";
 
@@ -313,10 +301,6 @@ if ( \$wgCommandLineMode ) {
 # Path to the GNU diff3 utility. Used for conflict resolution.
 \$wgDiff3 = \"{$this->values['wgDiff3']}\";
 
-# When you make changes to this configuration file, this will make
-# sure that cached pages are cleared.
-\$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
-
 # Enabled Extensions. Most extensions are enabled by including the base extension file here
 # but check specific extension documentation for more details
 ";
index 794776d..292604a 100644 (file)
@@ -61,11 +61,10 @@ if ( file_exists( "$IP/StartProfiler.php" ) ) {
 // Some other requires
 require_once( "$IP/includes/AutoLoader.php" );
 require_once( "$IP/includes/Defines.php" );
+require_once( "$IP/includes/DefaultSettings.php" );
 
 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
        # Use a callback function to configure MediaWiki
-       require_once( "$IP/includes/DefaultSettings.php" );
-
        $callback = MW_CONFIG_CALLBACK;
        # PHP 5.1 doesn't support "class::method" for call_user_func, so split it
        if ( strpos( $callback, '::' ) !== false ) {