From: Brion Vibber Date: Sat, 17 Jul 2004 23:52:11 +0000 (+0000) Subject: The last checkin broke the wiki on installations where TMP is not set X-Git-Tag: 1.5.0alpha1~2654 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=853b4b96406f1e75b57b8bd78eb7e38fc0729f2c;p=lhc%2Fweb%2Fwiklou.git The last checkin broke the wiki on installations where TMP is not set 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. --- diff --git a/PHPTAL-NP-0.7.0/libs/PHPTAL.php b/PHPTAL-NP-0.7.0/libs/PHPTAL.php index 69a89a5e16..e3c0cd3fc9 100644 --- a/PHPTAL-NP-0.7.0/libs/PHPTAL.php +++ b/PHPTAL-NP-0.7.0/libs/PHPTAL.php @@ -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.