From 256a18c50f0c042ae80d931ab3bd54b09f0fafa0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 23 Oct 2012 12:18:32 +0300 Subject: Fix issues #134, #1911 --- system/database/DB_cache.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'system/database/DB_cache.php') 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.'/'; -- cgit v1.2.3-24-g4f1b From 5fd3ae8d33a4f5d3159b86683b9a670e973a63f5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 24 Oct 2012 14:55:35 +0300 Subject: [ci skip] style and phpdoc-related changes (rel #1295) --- system/database/DB_cache.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'system/database/DB_cache.php') diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php index bdd91867a..671147b3d 100644 --- a/system/database/DB_cache.php +++ b/system/database/DB_cache.php @@ -37,6 +37,12 @@ class CI_DB_Cache { public $CI; public $db; // allows passing of db object so that multiple database connections and returned db objects can be supported + /** + * Constructor + * + * @param &$db + * @return void + */ public function __construct(&$db) { // Assign the main CI object to $this->CI and load the file helper since we use it a lot @@ -90,6 +96,7 @@ class CI_DB_Cache { * The URI being requested will become the name of the cache sub-folder. * An MD5 hash of the SQL statement will become the cache file name * + * @param string $sql * @return string */ public function read($sql) @@ -111,6 +118,8 @@ class CI_DB_Cache { /** * Write a query to a cache file * + * @param string $sql + * @param object $object * @return bool */ public function write($sql, $object) @@ -144,7 +153,9 @@ class CI_DB_Cache { /** * Delete cache files within a particular directory * - * @return bool + * @param string $segment_one = '' + * @param string $segment_two = '' + * @return void */ public function delete($segment_one = '', $segment_two = '') { @@ -167,7 +178,7 @@ class CI_DB_Cache { /** * Delete all existing cache files * - * @return bool + * @return void */ public function delete_all() { -- cgit v1.2.3-24-g4f1b From 6df461a84a1915759111a1dce893c628bf805219 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 24 Oct 2012 14:57:37 +0300 Subject: [ci skip] Fix a docblock --- system/database/DB_cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB_cache.php') diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php index 671147b3d..d07c755c6 100644 --- a/system/database/DB_cache.php +++ b/system/database/DB_cache.php @@ -40,7 +40,7 @@ class CI_DB_Cache { /** * Constructor * - * @param &$db + * @param object &$db * @return void */ public function __construct(&$db) -- cgit v1.2.3-24-g4f1b