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 --- modules/gallery/helpers/gallery_installer.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'modules/gallery/helpers') 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() { -- 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/gallery/helpers') 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 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/gallery/helpers') 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/gallery/helpers') 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 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/gallery/helpers') 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