From a4100521d7a60a31e2f0c22d12fc0e371c201f8c Mon Sep 17 00:00:00 2001 From: Joe7 Date: Mon, 27 Dec 2010 14:03:11 +0100 Subject: Added limit on select as for the outcome it doesn't matter if there are 20 rows or just 1. Is sufficient to return straight after reading 1 row. --- modules/gallery/libraries/drivers/Cache/Database.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/gallery/libraries/drivers/Cache/Database.php b/modules/gallery/libraries/drivers/Cache/Database.php index b7822811..4f57b3da 100644 --- a/modules/gallery/libraries/drivers/Cache/Database.php +++ b/modules/gallery/libraries/drivers/Cache/Database.php @@ -34,6 +34,7 @@ class Cache_Database_Driver extends Cache_Driver { $count = db::build() ->where("key", "=", $id) ->where("expiration", ">=", time()) + ->limit("1") ->count_records("caches"); return $count > 0; } -- cgit v1.2.3 From f4ecb939f5f61f16715df2ed5a88f01d85926eb6 Mon Sep 17 00:00:00 2001 From: Joe7 Date: Mon, 27 Dec 2010 15:35:33 +0100 Subject: Using ON DUPLICATE KEY UPDATE instead of SELECT+UPDATE/INSERT style method (that does 2 trips to Database server and is less optimal). exists() method is not needed anymore thus got removed --- .../gallery/libraries/drivers/Cache/Database.php | 38 +++++----------------- 1 file changed, 8 insertions(+), 30 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/drivers/Cache/Database.php b/modules/gallery/libraries/drivers/Cache/Database.php index 4f57b3da..7eda5b30 100644 --- a/modules/gallery/libraries/drivers/Cache/Database.php +++ b/modules/gallery/libraries/drivers/Cache/Database.php @@ -24,21 +24,6 @@ class Cache_Database_Driver extends Cache_Driver { // Kohana database instance protected $db; - /** - * Checks if a cache id is already set. - * - * @param string cache id - * @return boolean - */ - public function exists($id) { - $count = db::build() - ->where("key", "=", $id) - ->where("expiration", ">=", time()) - ->limit("1") - ->count_records("caches"); - return $count > 0; - } - /** * Sets a cache item to the given data, tags, and lifetime. * @@ -60,22 +45,15 @@ class Cache_Database_Driver extends Cache_Driver { $lifetime += time(); } + $db = Database::instance(); + $tags = $db->escape($tags); foreach ($items as $id => $data) { - if ($this->exists($id)) { - $status = db::build() - ->update("caches") - ->set("tags", $tags) - ->set("expiration", $lifetime) - ->set("cache", serialize($data)) - ->where("key", "=", $id) - ->execute(); - } else { - $status = db::build() - ->insert("caches") - ->columns("key", "tags", "expiration", "cache") - ->values($id, $tags, $lifetime, serialize($data)) - ->execute(); - } + $id = $db->escape($id); + $data = $db->escape(serialize($data)); + $db->query("INSERT INTO {caches} (`key`, `tags`, `expiration`, `cache`) + VALUES ('$id', '$tags', $lifetime, '$data') + ON DUPLICATE KEY UPDATE + `tags`=VALUES(tags), `expiration`=VALUES(expiration), `cache`=VALUES(cache)"); } return true; -- cgit v1.2.3 From 15792c4ddfec9741324c6968cc3e70fb23cef8ad Mon Sep 17 00:00:00 2001 From: Joe7 Date: Mon, 27 Dec 2010 22:16:29 +0100 Subject: Added changes to installer and upgrader scripts to support INSERT ON DUPLICATE KEY UPDATE SYNTAX in cache lib --- installer/install.sql | 2 +- modules/gallery/helpers/gallery_installer.php | 7 ++++++- modules/gallery/module.info | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index 427a3283..baee2b9d 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -43,7 +43,7 @@ CREATE TABLE {caches} ( `expiration` int(9) NOT NULL, `cache` longblob, PRIMARY KEY (`id`), - KEY `key` (`key`), + UNIQUE KEY `key` (`key`), KEY `tags` (`tags`) ) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index a6b8e6a2..ecabc766 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -309,7 +309,7 @@ class gallery_installer { module::set_var("gallery", "show_user_profiles_to", "registered_users"); module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin"); - module::set_version("gallery", 41); + module::set_version("gallery", 42); } static function upgrade($version) { @@ -642,6 +642,11 @@ class gallery_installer { module::clear_var("gallery", "_cache"); module::set_version("gallery", $version = 41); } + + if ($version == 41) { + $db->query("ALTER TABLE {caches} DROP INDEX `key`, ADD UNIQUE `key` (`key`)"); + module::set_version("gallery", $version = 42); + } } static function uninstall() { diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 2b684e5e..0cc3f6d1 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 41 +version = 42 -- cgit v1.2.3 From 3c31237406a4a55bfc0955ca433a1be0aec210a7 Mon Sep 17 00:00:00 2001 From: Joe7 Date: Tue, 28 Dec 2010 18:42:43 +0100 Subject: Truncating table first againt collides when converting INDEX into Unique --- modules/gallery/helpers/gallery_installer.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index ecabc766..97a3fb83 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -644,6 +644,7 @@ class gallery_installer { } if ($version == 41) { + $db->query("TRUNCATE TABLE {caches}"); $db->query("ALTER TABLE {caches} DROP INDEX `key`, ADD UNIQUE `key` (`key`)"); module::set_version("gallery", $version = 42); } -- cgit v1.2.3 From c5473ec4c070a4e548b5c2f83c9c0ece372d11d2 Mon Sep 17 00:00:00 2001 From: Joe7 Date: Tue, 28 Dec 2010 22:28:55 +0100 Subject: Coding style fixes: identation on line 48+removed trailing whitespaces, added spaces around =s --- modules/gallery/libraries/drivers/Cache/Database.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/drivers/Cache/Database.php b/modules/gallery/libraries/drivers/Cache/Database.php index 7eda5b30..2e773ca4 100644 --- a/modules/gallery/libraries/drivers/Cache/Database.php +++ b/modules/gallery/libraries/drivers/Cache/Database.php @@ -45,15 +45,15 @@ class Cache_Database_Driver extends Cache_Driver { $lifetime += time(); } - $db = Database::instance(); + $db = Database::instance(); $tags = $db->escape($tags); foreach ($items as $id => $data) { $id = $db->escape($id); $data = $db->escape(serialize($data)); - $db->query("INSERT INTO {caches} (`key`, `tags`, `expiration`, `cache`) - VALUES ('$id', '$tags', $lifetime, '$data') - ON DUPLICATE KEY UPDATE - `tags`=VALUES(tags), `expiration`=VALUES(expiration), `cache`=VALUES(cache)"); + $db->query("INSERT INTO {caches} (`key`, `tags`, `expiration`, `cache`) + VALUES ('$id', '$tags', $lifetime, '$data') + ON DUPLICATE KEY UPDATE `tags` = VALUES(tags), `expiration` = VALUES(expiration), + `cache` = VALUES(cache)"); } return true; -- cgit v1.2.3 From 336632fea0a955d74099cd169b3178c01f250ff5 Mon Sep 17 00:00:00 2001 From: Joe7 Date: Mon, 3 Jan 2011 13:21:54 +0100 Subject: Keep view counters of all item types accurate Added common increment_view_count() func in item model for reuse --- modules/gallery/controllers/albums.php | 5 +---- modules/gallery/controllers/movies.php | 3 +-- modules/gallery/controllers/photos.php | 3 +-- modules/gallery/models/item.php | 10 ++++++++++ 4 files changed, 13 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index b0887195..c0368488 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -71,10 +71,7 @@ class Albums_Controller extends Items_Controller { $template->set_global("parents", $album->parents()->as_array()); // view calls empty() on this $template->content = new View("album.html"); - // We can't use math in ORM or the query builder, so do this by hand. It's important - // that we do this with math, otherwise concurrent accesses will damage accuracy. - db::query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $album->id") - ->execute(); + $album->increment_view_count(); print $template; } diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 717eb8aa..15d4f950 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -49,8 +49,7 @@ class Movies_Controller extends Items_Controller { $template->content = new View("movie.html"); - $movie->view_count++; - $movie->save(); + $movie->increment_view_count(); print $template; } diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index b22ac8e5..2dc22ca4 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -49,8 +49,7 @@ class Photos_Controller extends Items_Controller { $template->content = new View("photo.html"); - $photo->view_count++; - $photo->save(); + $photo->increment_view_count(); print $template; } diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index fc5c3ff9..d4df0a78 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -1078,6 +1078,16 @@ class Item_Model_Core extends ORM_MPTT { return $data; } + /** + * Increments the view counter of this item + * We can't use math in ORM or the query builder, so do this by hand. It's important + * that we do this with math, otherwise concurrent accesses will damage accuracy. + */ + public function increment_view_count() { + db::query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $this->id") + ->execute(); + } + private function _cache_buster($path) { return "?m=" . (string)(file_exists($path) ? filemtime($path) : 0); } -- cgit v1.2.3 From 7ce902d373ac67d2267a886c18238eb53dd98093 Mon Sep 17 00:00:00 2001 From: Joe7 Date: Mon, 3 Jan 2011 15:14:32 +0100 Subject: Removed accidental whitespace --- modules/gallery/models/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index d4df0a78..7ddcb4c2 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -1087,7 +1087,7 @@ class Item_Model_Core extends ORM_MPTT { db::query("UPDATE {items} SET `view_count` = `view_count` + 1 WHERE `id` = $this->id") ->execute(); } - + private function _cache_buster($path) { return "?m=" . (string)(file_exists($path) ? filemtime($path) : 0); } -- cgit v1.2.3 From b26eff7f23b970a7983baf5e211ba88968effb9d Mon Sep 17 00:00:00 2001 From: Joe7 Date: Mon, 3 Jan 2011 15:44:36 +0100 Subject: Bugfix: input validation validates description up to length of 65535 chars, but DB trimmed data over 2048 chars. Converting column into TEXT type. Note: The effective maximum length of a VARCHAR in MySQL 5.0.3 and later is subject to the maximum row size (65,535 bytes, which is shared among all columns) and the character set used. In contrast to CHAR, VARCHAR values are stored as a one-byte or two-byte length prefix plus data. The length prefix indicates the number of bytes in the value. A column uses one length byte if values require no more than 255 bytes, two length bytes if values may require more than 255 bytes. --- installer/install.sql | 2 +- modules/gallery/helpers/gallery_installer.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index 2a2bf269..7a0f99c4 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -152,7 +152,7 @@ CREATE TABLE {items} ( `album_cover_item_id` int(9) DEFAULT NULL, `captured` int(9) DEFAULT NULL, `created` int(9) DEFAULT NULL, - `description` varchar(2048) DEFAULT NULL, + `description` TEXT DEFAULT NULL, `height` int(9) DEFAULT NULL, `left_ptr` int(9) NOT NULL, `level` int(9) NOT NULL, diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index cb314527..90d6d4b7 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -309,7 +309,7 @@ class gallery_installer { module::set_var("gallery", "show_user_profiles_to", "registered_users"); module::set_var("gallery", "extra_binary_paths", "/usr/local/bin:/opt/local/bin:/opt/bin"); - module::set_version("gallery", 42); + module::set_version("gallery", 43); } static function upgrade($version) { @@ -648,6 +648,11 @@ class gallery_installer { $db->query("ALTER TABLE {caches} DROP INDEX `key`, ADD UNIQUE `key` (`key`)"); module::set_version("gallery", $version = 42); } + + if ($version == 42) { + $db->query("ALTER TABLE {items} CHANGE `description` `description` TEXT DEFAULT NULL"); + module::set_version("gallery", $version = 43); + } } static function uninstall() { -- cgit v1.2.3 From e6a5f39b9113fa9cfc526b873947e365793d4e3e Mon Sep 17 00:00:00 2001 From: Joe7 Date: Mon, 3 Jan 2011 20:07:12 +0100 Subject: case fix --- modules/gallery/helpers/gallery_installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 90d6d4b7..834a27fa 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -650,7 +650,7 @@ class gallery_installer { } if ($version == 42) { - $db->query("ALTER TABLE {items} CHANGE `description` `description` TEXT DEFAULT NULL"); + $db->query("ALTER TABLE {items} CHANGE `description` `description` text DEFAULT NULL"); module::set_version("gallery", $version = 43); } } -- cgit v1.2.3 From cfaa62370ecbdb3badf4ab68bbefa7cfedaea154 Mon Sep 17 00:00:00 2001 From: Joe7 Date: Sun, 2 Jan 2011 18:59:23 +0100 Subject: Reimplemented Kohana 2.3's View::set_global() with array support. Allows for cleaner code and fewer function calls. --- modules/gallery/controllers/albums.php | 17 +++++++++-------- modules/gallery/controllers/movies.php | 17 +++++++++-------- modules/gallery/controllers/photos.php | 17 +++++++++-------- modules/gallery/libraries/MY_View.php | 10 ++++++++-- 4 files changed, 35 insertions(+), 26 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index c0368488..e69f6b6d 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -61,14 +61,15 @@ class Albums_Controller extends Items_Controller { } $template = new Theme_View("page.html", "collection", "album"); - $template->set_global("page", $page); - $template->set_global("page_title", null); - $template->set_global("max_pages", $max_pages); - $template->set_global("page_size", $page_size); - $template->set_global("item", $album); - $template->set_global("children", $album->viewable()->children($page_size, $offset)); - $template->set_global("children_count", $children_count); - $template->set_global("parents", $album->parents()->as_array()); // view calls empty() on this + $template->set_global(array("page" => $page, + "page_title" => null, + "max_pages" => $max_pages, + "page_size" => $page_size, + "item" => $album, + "children" => $album->viewable()->children($page_size, $offset), + "children_count" => $children_count, + "parents" => $album->parents()->as_array())); + // view calls empty() on this $template->content = new View("album.html"); $album->increment_view_count(); diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 15d4f950..1ae969c7 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -38,14 +38,15 @@ class Movies_Controller extends Items_Controller { } $template = new Theme_View("page.html", "item", "movie"); - $template->set_global("item", $movie); - $template->set_global("children", array()); - $template->set_global("children_count", 0); - $template->set_global("parents", $movie->parents()->as_array()); - $template->set_global("next_item", $next_item); - $template->set_global("previous_item", $previous_item); - $template->set_global("sibling_count", $movie->parent()->viewable()->children_count($where)); - $template->set_global("position", $position); + $template->set_global(array("item" => $movie, + "children" => array(), + "children_count" => 0, + "parents" => $movie->parents()->as_array(), + "next_item" => $next_item, + "previous_item" => $previous_item, + "sibling_count" + => $movie->parent()->viewable()->children_count($where), + "position" => $position)); $template->content = new View("movie.html"); diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index 2dc22ca4..e795f336 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -38,14 +38,15 @@ class Photos_Controller extends Items_Controller { } $template = new Theme_View("page.html", "item", "photo"); - $template->set_global("item", $photo); - $template->set_global("children", array()); - $template->set_global("children_count", 0); - $template->set_global("parents", $photo->parents()->as_array()); - $template->set_global("next_item", $next_item); - $template->set_global("previous_item", $previous_item); - $template->set_global("sibling_count", $photo->parent()->viewable()->children_count($where)); - $template->set_global("position", $position); + $template->set_global(array("item" => $photo, + "children" => array(), + "children_count" => 0, + "parents" => $photo->parents()->as_array(), + "next_item" => $next_item, + "previous_item" => $previous_item, + "sibling_count" + => $photo->parent()->viewable()->children_count($where), + "position" => $position)); $template->content = new View("photo.html"); diff --git a/modules/gallery/libraries/MY_View.php b/modules/gallery/libraries/MY_View.php index ded77792..2230203a 100644 --- a/modules/gallery/libraries/MY_View.php +++ b/modules/gallery/libraries/MY_View.php @@ -23,8 +23,14 @@ class View extends View_Core { /** * Reimplement Kohana 2.3's View::set_global() functionality. */ - public function set_global($key, $value) { - View::$global_data[$key] = $value; + public function set_global($key, $value = NULL) { + if (is_array($key)) { + foreach ($key as $key2 => $value) { + View::$global_data[$key2] = $value; + } + } else { + View::$global_data[$key] = $value; + } } public function is_set($key=null) { -- cgit v1.2.3 From f364e8a96b47f0e4f674c8b36317fc80184b219a Mon Sep 17 00:00:00 2001 From: Joe7 Date: Mon, 3 Jan 2011 20:28:54 +0100 Subject: Using array support introduced in 8295201adf948ea35f21f75801b7a8bf36c27569 --- modules/gallery/libraries/Admin_View.php | 10 +++++----- modules/gallery/libraries/Theme_View.php | 10 +++++----- modules/search/controllers/search.php | 8 ++++---- modules/tag/controllers/tag.php | 12 ++++++------ 4 files changed, 20 insertions(+), 20 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Admin_View.php b/modules/gallery/libraries/Admin_View.php index bff13ace..28a003cc 100644 --- a/modules/gallery/libraries/Admin_View.php +++ b/modules/gallery/libraries/Admin_View.php @@ -34,11 +34,11 @@ class Admin_View_Core extends Gallery_View { $this->theme_name = Input::instance()->get("theme", $this->theme_name); } $this->sidebar = ""; - $this->set_global("theme", $this); - $this->set_global("user", identity::active_user()); - $this->set_global("page_type", "admin"); - $this->set_global("page_subtype", $name); - $this->set_global("page_title", null); + $this->set_global(array("theme" => $this, + "user" => identity::active_user(), + "page_type" => "admin", + "page_subtype" => $name, + "page_title" => null)); } public function admin_menu() { diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index d22bb03a..ba1862c0 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -37,11 +37,11 @@ class Theme_View_Core extends Gallery_View { } $this->item = null; $this->tag = null; - $this->set_global("theme", $this); - $this->set_global("user", identity::active_user()); - $this->set_global("page_type", $page_type); - $this->set_global("page_subtype", $page_subtype); - $this->set_global("page_title", null); + $this->set_global(array("theme" => $this, + "user" => identity::active_user(), + "page_type" => $page_type, + "page_subtype" => $page_subtype, + "page_title" => null)); if ($page_type == "collection") { $this->set_global("thumb_proportion", $this->thumb_proportion()); } diff --git a/modules/search/controllers/search.php b/modules/search/controllers/search.php index e5894f30..733bc9f7 100644 --- a/modules/search/controllers/search.php +++ b/modules/search/controllers/search.php @@ -34,10 +34,10 @@ class Search_Controller extends Controller { $max_pages = max(ceil($count / $page_size), 1); $template = new Theme_View("page.html", "collection", "search"); - $template->set_global("page", $page); - $template->set_global("max_pages", $max_pages); - $template->set_global("page_size", $page_size); - $template->set_global("children_count", $count); + $template->set_global(array("page" => $page, + "max_pages" => $max_pages, + "page_size" => $page_size, + "children_count" => $count)); $template->content = new View("search.html"); $template->content->items = $result; diff --git a/modules/tag/controllers/tag.php b/modules/tag/controllers/tag.php index 0e924f3d..7bfa7d58 100644 --- a/modules/tag/controllers/tag.php +++ b/modules/tag/controllers/tag.php @@ -35,12 +35,12 @@ class Tag_Controller extends Controller { } $template = new Theme_View("page.html", "collection", "tag"); - $template->set_global("page", $page); - $template->set_global("max_pages", $max_pages); - $template->set_global("page_size", $page_size); - $template->set_global("tag", $tag); - $template->set_global("children", $tag->items($page_size, $offset)); - $template->set_global("children_count", $children_count); + $template->set_global(array("page" => $page, + "max_pages" => $max_pages, + "page_size" => $page_size, + "tag" => $tag, + "children" => $tag->items($page_size, $offset), + "children_count" => $children_count)); $template->content = new View("dynamic.html"); $template->content->title = t("Tag: %tag_name", array("tag_name" => $tag->name)); -- cgit v1.2.3 From 4a882108259f9542a6c8f2ffe95c9ee0e1c102cd Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 3 Jan 2011 11:41:25 -0800 Subject: Follow on to cfaa62370ecbdb3badf4ab68bbefa7cfedaea154 to fix indentation. Fixes #1569. --- modules/gallery/controllers/albums.php | 18 +++++++++--------- modules/gallery/controllers/movies.php | 18 +++++++++--------- modules/gallery/controllers/photos.php | 18 +++++++++--------- 3 files changed, 27 insertions(+), 27 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/albums.php b/modules/gallery/controllers/albums.php index e69f6b6d..25df0da7 100644 --- a/modules/gallery/controllers/albums.php +++ b/modules/gallery/controllers/albums.php @@ -61,15 +61,15 @@ class Albums_Controller extends Items_Controller { } $template = new Theme_View("page.html", "collection", "album"); - $template->set_global(array("page" => $page, - "page_title" => null, - "max_pages" => $max_pages, - "page_size" => $page_size, - "item" => $album, - "children" => $album->viewable()->children($page_size, $offset), - "children_count" => $children_count, - "parents" => $album->parents()->as_array())); - // view calls empty() on this + $template->set_global( + array("page" => $page, + "page_title" => null, + "max_pages" => $max_pages, + "page_size" => $page_size, + "item" => $album, + "children" => $album->viewable()->children($page_size, $offset), + "parents" => $album->parents()->as_array(), // view calls empty() on this + "children_count" => $children_count)); $template->content = new View("album.html"); $album->increment_view_count(); diff --git a/modules/gallery/controllers/movies.php b/modules/gallery/controllers/movies.php index 1ae969c7..bf50abd5 100644 --- a/modules/gallery/controllers/movies.php +++ b/modules/gallery/controllers/movies.php @@ -38,15 +38,15 @@ class Movies_Controller extends Items_Controller { } $template = new Theme_View("page.html", "item", "movie"); - $template->set_global(array("item" => $movie, - "children" => array(), - "children_count" => 0, - "parents" => $movie->parents()->as_array(), - "next_item" => $next_item, - "previous_item" => $previous_item, - "sibling_count" - => $movie->parent()->viewable()->children_count($where), - "position" => $position)); + $template->set_global( + array("item" => $movie, + "children" => array(), + "children_count" => 0, + "parents" => $movie->parents()->as_array(), + "next_item" => $next_item, + "previous_item" => $previous_item, + "sibling_count" => $movie->parent()->viewable()->children_count($where), + "position" => $position)); $template->content = new View("movie.html"); diff --git a/modules/gallery/controllers/photos.php b/modules/gallery/controllers/photos.php index e795f336..d500a92e 100644 --- a/modules/gallery/controllers/photos.php +++ b/modules/gallery/controllers/photos.php @@ -38,15 +38,15 @@ class Photos_Controller extends Items_Controller { } $template = new Theme_View("page.html", "item", "photo"); - $template->set_global(array("item" => $photo, - "children" => array(), - "children_count" => 0, - "parents" => $photo->parents()->as_array(), - "next_item" => $next_item, - "previous_item" => $previous_item, - "sibling_count" - => $photo->parent()->viewable()->children_count($where), - "position" => $position)); + $template->set_global( + array("item" => $photo, + "children" => array(), + "children_count" => 0, + "parents" => $photo->parents()->as_array(), + "next_item" => $next_item, + "previous_item" => $previous_item, + "sibling_count" => $photo->parent()->viewable()->children_count($where), + "position" => $position)); $template->content = new View("photo.html"); -- cgit v1.2.3 From d74aad072d8ccca70efb1c8b673e8368566a1974 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 3 Jan 2011 12:25:51 -0800 Subject: Some small follow on fixes for #1559 and #1568: 1) Make database changes in gallery_installer::install() instead of in installer/install.ql 2) Bump the version number in modules/gallery/module.info --- installer/install.sql | 4 ++-- modules/gallery/helpers/gallery_installer.php | 4 ++-- modules/gallery/module.info | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/installer/install.sql b/installer/install.sql index 84a975ae..6aae8014 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -43,7 +43,7 @@ CREATE TABLE {caches} ( `expiration` int(9) NOT NULL, `cache` longblob, PRIMARY KEY (`id`), - KEY `key` (`key`), + UNIQUE KEY `key` (`key`), KEY `tags` (`tags`) ) DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -152,7 +152,7 @@ CREATE TABLE {items} ( `album_cover_item_id` int(9) DEFAULT NULL, `captured` int(9) DEFAULT NULL, `created` int(9) DEFAULT NULL, - `description` varchar(2048) DEFAULT NULL, + `description` text, `height` int(9) DEFAULT NULL, `left_ptr` int(9) NOT NULL, `level` int(9) NOT NULL, diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index 834a27fa..f7b8da5f 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -44,7 +44,7 @@ class gallery_installer { `expiration` int(9) NOT NULL, `cache` longblob, PRIMARY KEY (`id`), - KEY (`key`), + UNIQUE KEY (`key`), KEY (`tags`)) DEFAULT CHARSET=utf8;"); @@ -84,7 +84,7 @@ class gallery_installer { `album_cover_item_id` int(9) default NULL, `captured` int(9) default NULL, `created` int(9) default NULL, - `description` varchar(2048) default NULL, + `description` text default NULL, `height` int(9) default NULL, `left_ptr` int(9) NOT NULL, `level` int(9) NOT NULL, diff --git a/modules/gallery/module.info b/modules/gallery/module.info index 0cc3f6d1..eb579ab6 100644 --- a/modules/gallery/module.info +++ b/modules/gallery/module.info @@ -1,3 +1,3 @@ name = "Gallery 3" description = "Gallery core application" -version = 42 +version = 43 -- cgit v1.2.3