Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
merged branch mrbase/patch-1 (PR #172)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the master branch (closes #172).

Commits
-------

7a6dfff use getenv before sys_get_temp_dir to allow more flexibility

Discussion
----------

use getenv before sys_get_temp_dir to allow more flexibility

Using environment settings over system settings enables us to use different tmp dirs pr. virtual host

---------------------------------------------------------------------------

by fabpot at 2012-03-22T12:26:32Z

`sys_get_temp_dir()` actually uses the value of the `TMPDIR` environment variable on *nix systems. So, you can already override this value by setting `TMPDIR`. I have added a note about this possibility in the code (see 52d0b22).

---------------------------------------------------------------------------

by mrbase at 2012-03-22T12:33:11Z

True, but setting this in a virtualhost will not work, it needs to be set as a "real" env variable to be read.
Doing this would make things work in a shared host env as well.

``` apache
<VirtualHost>
  SetEnv TMPDIR /var/www/..../tmp
</VirtualHost>
```

``` php
echo sys_get_temp_dir();
```
Will not output "/var/www/..../tmp" but "/tmp"

---------------------------------------------------------------------------

by fabpot at 2012-03-22T12:51:57Z

understood now. In this case, we just need to add a call to `getenv` for TMPDIR.

---------------------------------------------------------------------------

by Exeu at 2012-10-12T14:45:28Z

Why this is not merged?
Currently we are running into the same issue which causes an open base dir restriction.
  • Loading branch information
fabpot committed Oct 25, 2012
2 parents 50a7db4 + 7a6dfff commit 162b5d0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/preferences.php
Expand Up @@ -12,9 +12,12 @@
// Without these lines the default caching mechanism is "array" but this uses a lot of memory.
// If possible, use a disk cache to enable attaching large attachments etc.
// You can override the default temporary directory by setting the TMPDIR environment variable.
if (function_exists('sys_get_temp_dir') && is_writable(sys_get_temp_dir())) {

$tmp = getenv('TMPDIR') ? getenv('TMPDIR') : (function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : false);

if ($tmp && is_writable($tmp)) {
Swift_Preferences::getInstance()
-> setTempDir(sys_get_temp_dir())
-> setTempDir($tmp)
-> setCacheType('disk');
}

Expand Down

0 comments on commit 162b5d0

Please sign in to comment.