r4313 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r4312‎ | r4313 | r4314 >
Date:23:52, 17 July 2004
Author:vibber
Status:old
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/PHPTAL-NP-0.7.0/libs/PHPTAL.php (modified) (history)

Diff [purge]

Index: trunk/phase3/PHPTAL-NP-0.7.0/libs/PHPTAL.php
@@ -67,12 +67,27 @@
6868 define('PHPTAL_MARK', str_replace('.', '_', PHPTAL_VERSION) . '_');
6969
7070 if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
71 - define('PHPTAL_DEFAULT_CACHE_DIR', getenv("TMP") . "\\");
 71+ $default_temp = "C:\\Windows\\Temp";
7272 } else {
73 - global $wgUploadDirectory;
74 - define('PHPTAL_DEFAULT_CACHE_DIR', $wgUploadDirectory.'/');
 73+ $default_temp = "/tmp";
7574 }
 75+if( getenv( 'TMP' ) == "" ) {
 76+ if( is_writable( $default_temp ) ) {
 77+ define('PHPTAL_DEFAULT_CACHE_DIR', $default_temp.DIRECTORY_SEPARATOR);
 78+ } else {
 79+ global $wgUploadDirectory;
 80+ define('PHPTAL_DEFAULT_CACHE_DIR', $wgUploadDirectory.DIRECTORY_SEPARATOR);
 81+ }
 82+} else {
 83+ define('PHPTAL_DEFAULT_CACHE_DIR', getenv("TMP") . DIRECTORY_SEPARATOR);
 84+}
7685
 86+if( !is_writable (PHPTAL_DEFAULT_CACHE_DIR) )
 87+ die( htmlspecialchars(
 88+ 'Can\'t find a writable temp directory for the XHTML template. ' .
 89+ 'Check that the TMP environment variable points to a writable directory, ' .
 90+ 'or that the default temp dir (' . $default_temp . ') exists and is writable.' ) );
 91+
7792 /**
7893 * This define is used to select the templates output format.
7994 *

Status & tagging log