diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-10-23 11:18:32 +0200 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-10-23 11:18:32 +0200 |
commit | 256a18c50f0c042ae80d931ab3bd54b09f0fafa0 (patch) | |
tree | 9fceaab178250c1297da97fd79073f9e1512b4b7 | |
parent | f837ed97b98f4e05b4cc55938c1e68bf947280d5 (diff) |
Fix issues #134, #1911
-rw-r--r-- | system/database/DB_cache.php | 16 | ||||
-rw-r--r-- | system/helpers/file_helper.php | 2 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 1 |
3 files changed, 7 insertions, 12 deletions
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php index ba9110382..bdd91867a 100644 --- a/system/database/DB_cache.php +++ b/system/database/DB_cache.php @@ -43,6 +43,8 @@ class CI_DB_Cache { $this->CI =& get_instance(); $this->db =& $db; $this->CI->load->helper('file'); + + $this->check_path(); } // -------------------------------------------------------------------- @@ -66,7 +68,9 @@ class CI_DB_Cache { } // Add a trailing slash to the path if needed - $path = preg_replace('/(.+?)\/*$/', '\\1/', $path); + $path = realpath($path) + ? rtrim(realpath($path), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR + : rtrim($path, '/').'/'; if ( ! is_dir($path) OR ! is_really_writable($path)) { @@ -90,11 +94,6 @@ class CI_DB_Cache { */ public function read($sql) { - if ( ! $this->check_path()) - { - return $this->db->cache_off(); - } - $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); $filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql); @@ -116,11 +115,6 @@ class CI_DB_Cache { */ public function write($sql, $object) { - if ( ! $this->check_path()) - { - return $this->db->cache_off(); - } - $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); $dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'; diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index e68bb7f7a..441345b05 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -109,7 +109,7 @@ if ( ! function_exists('delete_files')) function delete_files($path, $del_dir = FALSE, $level = 0, $htdocs = FALSE) { // Trim the trailing slash - $path = rtrim($path, DIRECTORY_SEPARATOR); + $path = rtrim($path, '/\\'); if ( ! $current_dir = @opendir($path)) { diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 0aea3bb32..4048395a8 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -374,6 +374,7 @@ Bug fixes for 3.0 - Fixed a bug (#1476, #1909) - :doc:`Pagination Library <libraries/pagination>` didn't take into account actual routing when determining the current page. - Fixed a bug (#1766) - :doc:`Query Builder <database/query_builder>` didn't always take into account the *dbprefix* setting. - Fixed a bug (#779) - :doc:`URI Class <libraries/uri>` didn't always trim slashes from the *uri_string* as shown in the documentation. +- Fixed a bug (#134) - :doc:`Database Caching <database/caching>` method ``delete_cache()`` didn't work in some cases due to *cachedir* not being initialized properly. Version 2.1.3 ============= |