mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
"Fixing segmentation fault if the TMP/* directories are not writable.
Corrected CakeLog::write() so it will only attempt to write the log file is LOGS directory is writable " git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6094 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
ae8ccbd817
commit
a09167a8a6
2 changed files with 39 additions and 9 deletions
44
cake/libs/cache/file.php
vendored
44
cake/libs/cache/file.php
vendored
|
@ -59,6 +59,20 @@ class FileEngine extends CacheEngine {
|
|||
* @access public
|
||||
*/
|
||||
var $settings = array();
|
||||
/**
|
||||
* Set to true if FileEngine::init(); and FileEngine::__active(); do not fail.
|
||||
*
|
||||
* @var boolean
|
||||
* @access private
|
||||
*/
|
||||
var $__active = false;
|
||||
/**
|
||||
* True unless FileEngine::__active(); fails
|
||||
*
|
||||
* @var boolean
|
||||
* @access private
|
||||
*/
|
||||
var $__init = true;
|
||||
/**
|
||||
* Initialize the Cache Engine
|
||||
*
|
||||
|
@ -80,11 +94,7 @@ class FileEngine extends CacheEngine {
|
|||
if(empty($this->settings['path'])) {
|
||||
return false;
|
||||
}
|
||||
if (!is_writable($this->settings['path'])) {
|
||||
trigger_error(sprintf(__('%s is not writable', true), $this->settings['path']), E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return $this->__active();
|
||||
}
|
||||
/**
|
||||
* Garbage collection. Permanently remove all expired and deleted data
|
||||
|
@ -105,7 +115,7 @@ class FileEngine extends CacheEngine {
|
|||
* @access public
|
||||
*/
|
||||
function write($key, &$data, $duration) {
|
||||
if (empty($data)) {
|
||||
if (empty($data) || !$this->__init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -140,7 +150,7 @@ class FileEngine extends CacheEngine {
|
|||
* @access public
|
||||
*/
|
||||
function read($key) {
|
||||
if($this->__setKey($key) === false) {
|
||||
if($this->__setKey($key) === false || !$this->__init) {
|
||||
return false;
|
||||
}
|
||||
if ($this->settings['lock']) {
|
||||
|
@ -168,7 +178,7 @@ class FileEngine extends CacheEngine {
|
|||
* @access public
|
||||
*/
|
||||
function delete($key) {
|
||||
if($this->__setKey($key) === false) {
|
||||
if($this->__setKey($key) === false || !$this->__init) {
|
||||
return false;
|
||||
}
|
||||
return $this->__File->delete();
|
||||
|
@ -181,6 +191,9 @@ class FileEngine extends CacheEngine {
|
|||
* @access public
|
||||
*/
|
||||
function clear($check) {
|
||||
if (!$this->__init) {
|
||||
return false;
|
||||
}
|
||||
$dir = dir($this->settings['path']);
|
||||
if ($check) {
|
||||
$now = time();
|
||||
|
@ -223,5 +236,20 @@ class FileEngine extends CacheEngine {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Determine is cache directory is writable
|
||||
*
|
||||
* @return boolean
|
||||
* @access private
|
||||
*/
|
||||
function __active() {
|
||||
if (!$this->__active && $this->__init && !is_writable($this->settings['path'])) {
|
||||
$this->__init = false;
|
||||
trigger_error(sprintf(__('%s is not writable', true), $this->settings['path']), E_USER_WARNING);
|
||||
} else {
|
||||
$this->__active = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -91,7 +91,9 @@ class CakeLog {
|
|||
}
|
||||
$output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $msg . "\n";
|
||||
$log = new File($filename);
|
||||
return $log->append($output);
|
||||
if ($log->writable()) {
|
||||
return $log->append($output);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Reference in a new issue