summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2010-03-20 01:57:33 +0100
committerDerek Jones <derek.jones@ellislab.com>2010-03-20 01:57:33 +0100
commitd99e603f47e10adc015d4b804352db71f0563062 (patch)
tree988f403d6347367ff7f1023bfa40138b595f2b14
parent5ed19b477072edb77aa4337be71551fae5d9736d (diff)
reordered logic in _display_cache() to eliminate a call to is_really_writable() on each page request unless it is_really_needed()
-rw-r--r--system/core/Output.php20
-rw-r--r--user_guide/changelog.html1
2 files changed, 10 insertions, 11 deletions
diff --git a/system/core/Output.php b/system/core/Output.php
index 0dcf2e46f..ac4129405 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -377,12 +377,7 @@ class CI_Output {
function _display_cache(&$CFG, &$URI)
{
$cache_path = ($CFG->item('cache_path') == '') ? BASEPATH.'cache/' : $CFG->item('cache_path');
-
- if ( ! is_dir($cache_path) OR ! is_really_writable($cache_path))
- {
- return FALSE;
- }
-
+
// Build the file path. The file name is an MD5 hash of the full URI
$uri = $CFG->item('base_url').
$CFG->item('index_page').
@@ -410,7 +405,7 @@ class CI_Output {
flock($fp, LOCK_UN);
fclose($fp);
-
+
// Strip out the embedded timestamp
if ( ! preg_match("/(\d+TS--->)/", $cache, $match))
{
@@ -419,10 +414,13 @@ class CI_Output {
// Has the file expired? If so we'll delete it.
if (time() >= trim(str_replace('TS--->', '', $match['1'])))
- {
- @unlink($filepath);
- log_message('debug', "Cache file has expired. File deleted");
- return FALSE;
+ {
+ if (is_really_writable($cache_path))
+ {
+ @unlink($filepath);
+ log_message('debug', "Cache file has expired. File deleted");
+ return FALSE;
+ }
}
// Display the cache
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 9615fd2b3..45c698289 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -124,6 +124,7 @@ Hg Tag: </p>
<li><kbd>get_mime_by_extension()</kbd> is now case insensitive.</li>
<li>Added "default" to the list <a href="general/reserved_names.html">Reserved Names</a>.</li>
<li>Added 'application/x-msdownload' for .exe files and ''application/x-gzip-compressed' for .tgz files to config/mimes.php.</li>
+ <li>Eliminated a call to is_really_writable() on each request unless it is really needed (Output caching)</li>
<li>Documented <kbd>append_output()</kbd> in the <a href="libraries/output.html">Output Class</a>.</li>
<li>Documented a second argument in the <kbd>decode()</kbd> function for the <a href="libraries/encryption.html">Encryption Class</a>.</li>
<li>Documentd db->close().</li>