* Reduce config file clutter by setting various script and upload paths
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 3 Jan 2007 08:41:16 +0000 (08:41 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 3 Jan 2007 08:41:16 +0000 (08:41 +0000)
  based on $IP or $wgScriptPath in Setup.php. They can still be explicitly
  overridden in LocalSettings.php if desired...

RELEASE-NOTES
config/index.php
includes/DefaultSettings.php
includes/Setup.php

index 520042d..ecad3c0 100644 (file)
@@ -451,6 +451,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 8461) Support watching pages on move
 * (bug 8041) Work around bug with debug_backtrace when Zend Optimizer is
   loaded by skipping the function. Use wfDebugBacktrace() wrapper function.
+* Reduce config file clutter by setting various script and upload paths
+  based on $IP or $wgScriptPath in Setup.php. They can still be explicitly
+  overridden in LocalSettings.php if desired...
 
 
 == Languages updated ==
index 3dffb67..a6e644b 100644 (file)
@@ -343,30 +343,8 @@ if( ini_get( "safe_mode" ) ) {
 }
 
 $sapi = php_sapi_name();
-$conf->prettyURLs = true;
 print "<li>PHP server API is $sapi; ";
-switch( $sapi ) {
-case "apache":
-case "apache2handler":
-       print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
-       break;
-case "cgi":
-case "cgi-fcgi":
-       // For some reason cgi.fix_pathinfo isn't retrievable via ini_get()
-       // but even if it is, it's not necessarily safe.
-       // @fixme add optional runtime testing...?
-       $conf->prettyURLs = false;
-       break;
-case "apache2filter":
-case "isapi":
-       // Pretty sure these two break from past tests
-       $conf->prettyURLs = false;
-       break;
-default:
-       print "unknown, assuming PATH_INFO broken for safety; ";
-       $conf->prettyURLs = false;
-}
-if( $conf->prettyURLs ) {
+if( $wgUsePathInfo ) {
        print "ok, using pretty URLs (<tt>index.php/Page_Title</tt>)";
 } else {
        print "using ugly URLs (<tt>index.php?title=Page_Title</tt>)";
@@ -1314,8 +1292,6 @@ function writeLocalSettings( $conf ) {
        $zlib = ($conf->zlib ? "" : "# ");
        $magic = ($conf->ImageMagick ? "" : "# ");
        $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
-       $pretty = ($conf->prettyURLs ? "" : "# ");
-       $ugly = ($conf->prettyURLs ? "# " : "");
        $rights = ($conf->RightsUrl) ? "" : "# ";
        $hashedUploads = $conf->safeMode ? '' : '# ';
 
@@ -1415,28 +1391,12 @@ if ( \$wgCommandLineMode ) {
 
 \$wgSitename         = \"{$slconf['Sitename']}\";
 
+## The URL base path to the directory containing the wiki;
+## defaults for all runtime URL paths are based off of this.
 \$wgScriptPath       = \"{$slconf['ScriptPath']}\";
-\$wgScript           = \"\$wgScriptPath/index.php\";
-\$wgRedirectScript   = \"\$wgScriptPath/redirect.php\";
 
 ## For more information on customizing the URLs please see:
-## http://meta.wikimedia.org/wiki/Eliminating_index.php_from_the_url
-
-## 'Pretty' URLs using PATH_INFO work on most configurations with
-## PHP configured as an Apache module.
-{$pretty}\$wgArticlePath      = \"\$wgScript/\$1\";
-
-## If using PHP as a CGI module, the ?title= style might have to be used
-## depending on the configuration. If it fails, try enabling the option
-## cgi.fix_pathinfo in php.ini, then switch to pretty URLs.
-{$ugly}\$wgArticlePath      = \"\$wgScript?title=\$1\";
-
-\$wgStylePath        = \"\$wgScriptPath/skins\";
-\$wgStyleDirectory   = \"\$IP/skins\";
-\$wgLogo             = \"\$wgStylePath/common/images/wiki.png\";
-
-\$wgUploadPath       = \"\$wgScriptPath/images\";
-\$wgUploadDirectory  = \"\$IP/images\";
+## http://www.mediawiki.org/wiki/Manual:Short_URL
 
 \$wgEnableEmail      = $enableemail;
 \$wgEnableUserEmail  = $enableuseremail;
@@ -1488,9 +1448,6 @@ if ( \$wgCommandLineMode ) {
 ## If you have the appropriate support software installed
 ## you can enable inline LaTeX equations:
 \$wgUseTeX           = false;
-\$wgMathPath         = \"{\$wgUploadPath}/math\";
-\$wgMathDirectory    = \"{\$wgUploadDirectory}/math\";
-\$wgTmpDirectory     = \"{\$wgUploadDirectory}/tmp\";
 
 \$wgLocalInterwiki   = \$wgSitename;
 
index 09281fd..468307b 100644 (file)
@@ -82,6 +82,11 @@ if(    isset( $_SERVER['SERVER_PORT'] )
 /**
  * The path we should point to.
  * It might be a virtual path in case with use apache mod_rewrite for example
+ *
+ * This *needs* to be set correctly.
+ *
+ * Other paths will be set to defaults based on it unless they are directly
+ * set in LocalSettings.php
  */
 $wgScriptPath      = '/wiki';
 
@@ -98,47 +103,63 @@ $wgScriptPath          = '/wiki';
  *
  * Override this to false if $_SERVER['PATH_INFO']
  * contains unexpectedly incorrect garbage, or to
- * true if it is known to be correct.
+ * true if it is really correct.
  *
- * Note that having this incorrectly set to true can
+ * The default $wgArticlePath will be set based on
+ * this value at runtime, but if you have customized
+ * it, having this incorrectly set to true can
  * cause redirect loops when "pretty URLs" are used.
+ *
  */
-$wgUsePathInfo         = ( strpos( php_sapi_name(), 'cgi' ) === false );
+$wgUsePathInfo =
+       ( strpos( php_sapi_name(), 'cgi' ) === false ) &&
+       ( strpos( php_sapi_name(), 'apache2filter' ) === false ) &&
+       ( strpos( php_sapi_name(), 'isapi' ) === false );
 
 
 /**#@+
  * Script users will request to get articles
  * ATTN: Old installations used wiki.phtml and redirect.phtml -
  * make sure that LocalSettings.php is correctly set!
- * @deprecated
+ *
+ * Will be set based on $wgScriptPath in Setup.php if not overridden
+ * in LocalSettings.php. Generally you should not need to change this
+ * unless you don't like seeing "index.php".
  */
-$wgScript           = "{$wgScriptPath}/index.php";
-$wgRedirectScript   = "{$wgScriptPath}/redirect.php";
+$wgScript           = false; /// defaults to "{$wgScriptPath}/index.php"
+$wgRedirectScript   = false; /// defaults to "{$wgScriptPath}/redirect.php"
 /**#@-*/
 
 
 /**#@+
+ * These various web and file path variables are set to their defaults
+ * in Setup.php if they are not explicitly set from LocalSettings.php.
+ * If you do override them, be sure to set them all!
+ *
+ * These will relatively rarely need to be set manually, unless you are
+ * splitting style sheets or images outside the main document root.
+ *
  * @global string
  */
 /**
  * style path as seen by users
  */
-$wgStylePath   = "{$wgScriptPath}/skins";
+$wgStylePath   = false; /// defaults to "{$wgScriptPath}/skins"
 /**
  * filesystem stylesheets directory
  */
-$wgStyleDirectory = "{$IP}/skins";
+$wgStyleDirectory = false; /// defaults to "{$IP}/skins"
 $wgStyleSheetPath = &$wgStylePath;
-$wgArticlePath      = "{$wgScript}?title=$1";
+$wgArticlePath      = false; /// default to "{$wgScript}/$1" or "{$wgScript}?title=$1", depending on $wgUsePathInfo
 $wgVariantArticlePath = false;
-$wgUploadPath       = "{$wgScriptPath}/images";
-$wgUploadDirectory     = "{$IP}/images";
+$wgUploadPath       = false; /// defaults to "{$wgScriptPath}/images"
+$wgUploadDirectory     = false; /// defaults to "{$IP}/images"
 $wgHashedUploadDirectory       = true;
-$wgLogo                                = "{$wgUploadPath}/wiki.png";
+$wgLogo                                = false; /// defaults to "{$wgStylePath}/common/images/wiki.png"
 $wgFavicon                     = '/favicon.ico';
-$wgMathPath         = "{$wgUploadPath}/math";
-$wgMathDirectory    = "{$wgUploadDirectory}/math";
-$wgTmpDirectory     = "{$wgUploadDirectory}/tmp";
+$wgMathPath         = false; /// defaults to "{$wgUploadPath}/math"
+$wgMathDirectory    = false; /// defaults to "{$wgUploadDirectory}/math"
+$wgTmpDirectory     = false; /// defaults to "{$wgUploadDirectory}/tmp"
 $wgUploadBaseUrl    = "";
 /**#@-*/
 
index 387805f..8a9436e 100644 (file)
@@ -28,6 +28,30 @@ if ( !isset( $wgVersion ) ) {
        die( 1 );
 }
 
+// Set various default paths sensibly...
+if( $wgScript === false ) $wgScript = "$wgScriptPath/index.php";
+if( $wgRedirectScript === false ) $wgRedirectScript = "$wgScriptPath/redirect.php";
+
+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";
+
 require_once( "$IP/includes/AutoLoader.php" );
 
 wfProfileIn( $fname.'-exception' );