diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gallery/helpers/gallery_installer.php | 14 | ||||
-rw-r--r-- | modules/gallery/libraries/drivers/Cache/Database.php | 13 | ||||
-rw-r--r-- | modules/gallery/module.info | 2 |
3 files changed, 19 insertions, 10 deletions
diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index d0bfa629..c3c3543c 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -33,7 +33,8 @@ class gallery_installer { ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {caches} ( - `id` varchar(255) NOT NULL, + `id` int(9) NOT NULL auto_increment, + `key` varchar(255) NOT NULL, `tags` varchar(255), `expiration` int(9) NOT NULL, `cache` longblob, @@ -287,11 +288,20 @@ class gallery_installer { ENGINE=InnoDB DEFAULT CHARSET=utf8;"); module::set_version("gallery", $version = 4); } + if ($version == 4) { Cache::instance()->delete_all(); - $db->query("ALTER TABLE {caches} modify column cache LONGBLOB"); + $db->query("ALTER TABLE {caches} MODIFY COLUMN `cache` LONGBLOB"); module::set_version("gallery", $version = 5); } + + if ($version == 5) { + Cache::instance()->delete_all(); + $db->query("ALTER TABLE {caches} DROP COLUMN `id`"); + $db->query("ALTER TABLE {caches} ADD COLUMN `key` varchar(255) NOT NULL"); + $db->query("ALTER TABLE {caches} ADD COLUMN `id` int(9) NOT NULL auto_increment PRIMARY KEY"); + module::set_version("gallery", $version = 6); + } } static function uninstall() { diff --git a/modules/gallery/libraries/drivers/Cache/Database.php b/modules/gallery/libraries/drivers/Cache/Database.php index 158f7b3a..f3a1eb02 100644 --- a/modules/gallery/libraries/drivers/Cache/Database.php +++ b/modules/gallery/libraries/drivers/Cache/Database.php @@ -32,9 +32,8 @@ class Cache_Database_Driver implements Cache_Driver { $this->db = Database::instance(); if (!$this->db->table_exists("caches")) { - throw new Kohana_Exception("cache.driver_error", "Cache table is not defined"); + throw new Exception("@todo Cache table is not defined"); } - Kohana::log("debug", "Cache Database Driver Initialized"); } /** @@ -44,7 +43,7 @@ class Cache_Database_Driver implements Cache_Driver { * @return boolean */ public function exists($id) { - $count = $this->db->count_records("caches", array("id" => $id, "expiration >=" => time())); + $count = $this->db->count_records("caches", array("key" => $id, "expiration >=" => time())); return $count > 0; } @@ -70,10 +69,10 @@ class Cache_Database_Driver implements Cache_Driver { if ($this->exists($id)) { $status = $this->db->update("caches", - array("tags" => $tags, "expiration" => $lifetime, "cache" => $data), array("id" => $id)); + array("tags" => $tags, "expiration" => $lifetime, "cache" => $data), array("key" => $id)); } else { $status = $this->db->insert("caches", - array("id" => $id, "tags" => $tags, "expiration" => $lifetime, "cache" => $data)); + array("key" => $id, "tags" => $tags, "expiration" => $lifetime, "cache" => $data)); } return count($status) > 0; @@ -119,7 +118,7 @@ class Cache_Database_Driver implements Cache_Driver { */ public function get($id) { $data = null; - $result = $this->db->getwhere("caches", array("id" => $id)); + $result = $this->db->getwhere("caches", array("key" => $id)); if (count($result) > 0) { $cache = $result->current(); @@ -157,7 +156,7 @@ class Cache_Database_Driver implements Cache_Driver { } else if ($tag === true) { $this->db->like("tags", "<$id>"); } else { - $this->db->where("id", $id); + $this->db->where("key", $id); } $status = $this->db->delete(); diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 817fdddd..c184aba7 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = Gallery 3 description = Gallery core application -version = 5 +version = 6 |