r77878 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77877‎ | r77878 | r77879 >
Date:15:00, 6 December 2010
Author:tstarling
Status:ok (Comments)
Tags:
Comment:
Remove some of the rubbish that has been accumulating in the default LocalSettings.php for years, especially code as opposed to configuration data:
* 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.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/RecentChange.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/WebStart.php (modified) (history)
  • /trunk/phase3/includes/installer/LocalSettingsGenerator.php (modified) (history)
  • /trunk/phase3/maintenance/doMaintenance.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/doMaintenance.php
@@ -61,11 +61,10 @@
6262 // Some other requires
6363 require_once( "$IP/includes/AutoLoader.php" );
6464 require_once( "$IP/includes/Defines.php" );
 65+require_once( "$IP/includes/DefaultSettings.php" );
6566
6667 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
6768 # Use a callback function to configure MediaWiki
68 - require_once( "$IP/includes/DefaultSettings.php" );
69 -
7069 $callback = MW_CONFIG_CALLBACK;
7170 # PHP 5.1 doesn't support "class::method" for call_user_func, so split it
7271 if ( strpos( $callback, '::' ) !== false ) {
Index: trunk/phase3/includes/RecentChange.php
@@ -674,7 +674,7 @@
675675 $flag .= ($rc_new ? "N" : "") . ($rc_minor ? "M" : "") . ($rc_bot ? "B" : "");
676676 }
677677
678 - if ( $wgRC2UDPInterwikiPrefix === true ) {
 678+ if ( $wgRC2UDPInterwikiPrefix === true && $wgLocalInterwiki !== false ) {
679679 $prefix = $wgLocalInterwiki;
680680 } elseif ( $wgRC2UDPInterwikiPrefix ) {
681681 $prefix = $wgRC2UDPInterwikiPrefix;
Index: trunk/phase3/includes/Setup.php
@@ -289,6 +289,9 @@
290290 else $wgHtml5Version = 'HTML+RDFa 1.0';
291291 }
292292
 293+if ( $wgInvalidateCacheOnLocalSettingsChange ) {
 294+ $wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( "$IP/LocalSettings.php" ) ) );
 295+}
293296
294297 wfProfileOut( $fname.'-misc1' );
295298 wfProfileIn( $fname.'-memcached' );
Index: trunk/phase3/includes/installer/LocalSettingsGenerator.php
@@ -197,21 +197,11 @@
198198 # Further documentation for configuration settings may be found at:
199199 # http://www.mediawiki.org/wiki/Manual:Configuration_settings
200200
201 -# If you customize your file layout, set \$IP to the directory that contains
202 -# the other MediaWiki files. It will be used as a base to locate files.
203 -if( defined( 'MW_INSTALL_PATH' ) ) {
204 - \$IP = MW_INSTALL_PATH;
205 -} else {
206 - \$IP = dirname( __FILE__ );
 201+# Protect against web entry
 202+if ( !defined( 'MEDIAWIKI' ) ) {
 203+ exit;
207204 }
208205
209 -require_once( \"\$IP/includes/DefaultSettings.php\" );
210 -
211 -if ( \$wgCommandLineMode ) {
212 - if ( isset( \$_SERVER ) && array_key_exists( 'REQUEST_METHOD', \$_SERVER ) ) {
213 - die( \"This script must be run from the command line\\n\" );
214 - }
215 -}
216206 ## Uncomment this to disable output compression
217207 # \$wgDisableOutputCompression = true;
218208
@@ -285,8 +275,6 @@
286276 ## be publically accessible from the web.
287277 #\$wgCacheDirectory = \"\$IP/cache\";
288278
289 -\$wgLocalInterwiki = strtolower( \$wgSitename );
290 -
291279 # Site language code, should be one of ./languages/Language(.*).php
292280 \$wgLanguageCode = \"{$this->values['wgLanguageCode']}\";
293281
@@ -313,10 +301,6 @@
314302 # Path to the GNU diff3 utility. Used for conflict resolution.
315303 \$wgDiff3 = \"{$this->values['wgDiff3']}\";
316304
317 -# When you make changes to this configuration file, this will make
318 -# sure that cached pages are cleared.
319 -\$wgCacheEpoch = max( \$wgCacheEpoch, gmdate( 'YmdHis', @filemtime( __FILE__ ) ) );
320 -
321305 # Enabled Extensions. Most extensions are enabled by including the base extension file here
322306 # but check specific extension documentation for more details
323307 ";
Index: trunk/phase3/includes/WebStart.php
@@ -91,11 +91,11 @@
9292
9393 # Start the autoloader, so that extensions can derive classes from core files
9494 require_once( "$IP/includes/AutoLoader.php" );
 95+# Load default settings
 96+require_once( "$IP/includes/DefaultSettings.php" );
9597
9698 if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
9799 # Use a callback function to configure MediaWiki
98 - require_once( "$IP/includes/DefaultSettings.php" );
99 -
100100 $callback = MW_CONFIG_CALLBACK;
101101 # PHP 5.1 doesn't support "class::method" for call_user_func, so split it
102102 if ( strpos( $callback, '::' ) !== false ) {
@@ -110,7 +110,6 @@
111111 # the wiki installer needs to be launched or the generated file moved from
112112 # ./config/ to ./
113113 if( !file_exists( MW_CONFIG_FILE ) ) {
114 - require_once( "$IP/includes/DefaultSettings.php" ); # used for printing the version
115114 require_once( "$IP/includes/templates/NoLocalSettings.php" );
116115 die();
117116 }
Index: trunk/phase3/includes/Title.php
@@ -2645,7 +2645,9 @@
26462646 $this->mInterwiki = $wgContLang->lc( $p );
26472647
26482648 # Redundant interwiki prefix to the local wiki
2649 - if ( 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) ) {
 2649+ if ( $wgLocalInterwiki !== false
 2650+ && 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) )
 2651+ {
26502652 if ( $dbkey == '' ) {
26512653 # Can't have an empty self-link
26522654 return false;
Index: trunk/phase3/includes/DefaultSettings.php
@@ -26,7 +26,6 @@
2727 die( 1 );
2828 }
2929
30 -
3130 # Create a site configuration object. Not used for much in a default install
3231 if ( !defined( 'MW_PHP4' ) ) {
3332 require_once( "$IP/includes/SiteConfiguration.php" );
@@ -140,7 +139,6 @@
141140 * Defaults to "{$wgScriptPath}/redirect{$wgScriptExtension}".
142141 */
143142 $wgRedirectScript = false; ///< defaults to
144 -/**@}*/
145143
146144 /**
147145 * The URL path to load.php.
@@ -149,6 +147,8 @@
150148 */
151149 $wgLoadScript = false;
152150
 151+/**@}*/
 152+
153153 /************************************************************************//**
154154 * @name URLs and file paths
155155 *
@@ -1665,6 +1665,17 @@
16661666 */
16671667 $wgClockSkewFudge = 5;
16681668
 1669+/**
 1670+ * Invalidate various caches when LocalSettings.php changes. This is equivalent
 1671+ * to setting $wgCacheEpoch to the modification time of LocalSettings.php, as
 1672+ * was previously done in the default LocalSettings.php file.
 1673+ *
 1674+ * On high-traffic wikis, this should be set to false, to avoid the need to
 1675+ * check the file modification time, and to avoid the performance impact of
 1676+ * unnecessary cache invalidations.
 1677+ */
 1678+$wgInvalidateCacheOnLocalSettingsChange = true;
 1679+
16691680 /** @} */ # end of cache settings
16701681
16711682 /************************************************************************//**
@@ -2486,9 +2497,16 @@
24872498 */
24882499 $wgLegalTitleChars = " %!\"$&'()*,\\-.\\/0-9:;=?@A-Z\\\\^_`a-z~\\x80-\\xFF+";
24892500
2490 -$wgLocalInterwiki = 'w';
2491 -$wgInterwikiExpiry = 10800; # Expiry time for cache of interwiki table
 2501+/**
 2502+ * The interwiki prefix of the current wiki, or false if it doesn't have one.
 2503+ */
 2504+$wgLocalInterwiki = false;
24922505
 2506+/**
 2507+ * Expiry time for cache of interwiki table
 2508+ */
 2509+$wgInterwikiExpiry = 10800;
 2510+
24932511 /** Interwiki caching settings.
24942512 $wgInterwikiCache specifies path to constant database file
24952513 This cdb database is generated by dumpInterwiki from maintenance
Index: trunk/phase3/RELEASE-NOTES
@@ -91,6 +91,11 @@
9292 the footers of skins.
9393 * $wgFileCacheDepth can be used to set the depth of the subdirectory hierarchy
9494 used for the file cache. Default value is 2, which matches former behavior
 95+* It's no longer necessary for LocalSettings.php to include DefaultSettings.php.
 96+* It's no longer necessary to set $wgCacheEpoch to the file modification time
 97+ of LocalSettings.php, in LocalSettings.php itself. Instead, this is done
 98+ automatically if $wgInvalidateCacheOnLocalSettingsChange is true (which is
 99+ the default).
95100
96101 === New features in 1.17 ===
97102 * (bug 10183) Users can now add personal styles and scripts to all skins via

Follow-up revisions

RevisionCommit summaryAuthorDate
r77879Update for r77878: $wgLocalInterwiki may now be false.tstarling15:02, 6 December 2010
r784371.17: Merge tagged revisions from trunk: r77878, r77981, r77982, r77994, r780...catrope14:14, 15 December 2010

Comments

#Comment by Werdna (talk | contribs)   01:06, 9 December 2010

I've looked over this, and it looks OK to me, but I'm not updating its status.

Status & tagging log