Added option to set cache file permissions.
This commit is contained in:
committed by
Justin Hileman
parent
042d537992
commit
197a2b6807
@@ -39,6 +39,7 @@ class Mustache_Engine
|
|||||||
private $helpers;
|
private $helpers;
|
||||||
private $escape;
|
private $escape;
|
||||||
private $charset = 'UTF-8';
|
private $charset = 'UTF-8';
|
||||||
|
private $cacheFilePerm = 0644;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mustache class constructor.
|
* Mustache class constructor.
|
||||||
@@ -76,6 +77,9 @@ class Mustache_Engine
|
|||||||
*
|
*
|
||||||
* // character set for `htmlspecialchars`. Defaults to 'UTF-8'
|
* // character set for `htmlspecialchars`. Defaults to 'UTF-8'
|
||||||
* 'charset' => 'ISO-8859-1',
|
* 'charset' => 'ISO-8859-1',
|
||||||
|
*
|
||||||
|
* // permissions for cache files. Defaults to 0644
|
||||||
|
* 'cache_file_perm' => 0666,
|
||||||
* );
|
* );
|
||||||
*
|
*
|
||||||
* @param array $options (default: array())
|
* @param array $options (default: array())
|
||||||
@@ -117,6 +121,10 @@ class Mustache_Engine
|
|||||||
if (isset($options['charset'])) {
|
if (isset($options['charset'])) {
|
||||||
$this->charset = $options['charset'];
|
$this->charset = $options['charset'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($options['cache_file_perm'])) {
|
||||||
|
$this->cacheFilePerm = $options['cache_file_perm'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -580,7 +588,7 @@ class Mustache_Engine
|
|||||||
$tempFile = tempnam(dirname($fileName), basename($fileName));
|
$tempFile = tempnam(dirname($fileName), basename($fileName));
|
||||||
if (false !== @file_put_contents($tempFile, $source)) {
|
if (false !== @file_put_contents($tempFile, $source)) {
|
||||||
if (@rename($tempFile, $fileName)) {
|
if (@rename($tempFile, $fileName)) {
|
||||||
chmod($fileName, 0644);
|
chmod($fileName, $this->cacheFilePerm);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user