The last checkin broke the wiki on installations where TMP is not set
authorBrion Vibber <brion@users.mediawiki.org>
Sat, 17 Jul 2004 23:52:11 +0000 (23:52 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Sat, 17 Jul 2004 23:52:11 +0000 (23:52 +0000)
and the upload directory is not writable (ie, default install!)

Now checks a system-dependent default temp dir first (/tmp or
C:\Windows\Temp) and then falls back to upload dir. (TMP takes
priority over either.) If the dir is not writable, print out
an explanatory message for the poor sap trying to figure out
why the wiki isn't working.

Some of this crud shouldn't go in PHPTAL if possible, since it's
rather mediawiki-specific.

PHPTAL-NP-0.7.0/libs/PHPTAL.php

index 69a89a5..e3c0cd3 100644 (file)
@@ -67,11 +67,26 @@ define('PHPTAL_VERSION', '0.7.0');
 define('PHPTAL_MARK', str_replace('.', '_', PHPTAL_VERSION) . '_');
 
 if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
-    define('PHPTAL_DEFAULT_CACHE_DIR', getenv("TMP") . "\\");
+       $default_temp = "C:\\Windows\\Temp";
 } else {
-       global $wgUploadDirectory;
-       define('PHPTAL_DEFAULT_CACHE_DIR', $wgUploadDirectory.'/');
+       $default_temp = "/tmp";
 }
+if( getenv( 'TMP' ) == "" ) {
+       if( is_writable( $default_temp ) ) {
+               define('PHPTAL_DEFAULT_CACHE_DIR', $default_temp.DIRECTORY_SEPARATOR);
+       } else {
+               global $wgUploadDirectory;
+               define('PHPTAL_DEFAULT_CACHE_DIR', $wgUploadDirectory.DIRECTORY_SEPARATOR);
+       }
+} else {
+    define('PHPTAL_DEFAULT_CACHE_DIR', getenv("TMP") . DIRECTORY_SEPARATOR);
+}
+
+if( !is_writable (PHPTAL_DEFAULT_CACHE_DIR) )
+       die( htmlspecialchars(
+               'Can\'t find a writable temp directory for the XHTML template. ' .
+               'Check that the TMP environment variable points to a writable directory, ' .
+               'or that the default temp dir (' . $default_temp . ') exists and is writable.' ) );
 
 /**
  * This define is used to select the templates output format.