From 10785b1e820c5e10d982c6b49125903886f7b889 Mon Sep 17 00:00:00 2001 From: Kriss Andsten Date: Thu, 27 Jan 2011 03:05:40 +0100 Subject: Extend comment module field lenghts to fit IPv6 remote host addresses and long (but legally so) hostnames. --- modules/comment/helpers/comment_installer.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'modules/comment/helpers') diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index 48b6ee21..cd20ef72 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -37,8 +37,8 @@ class comment_installer { `server_http_referer` varchar(255) default NULL, `server_http_user_agent` varchar(128) default NULL, `server_query_string` varchar(64) default NULL, - `server_remote_addr` varchar(32) default NULL, - `server_remote_host` varchar(64) default NULL, + `server_remote_addr` varchar(40) default NULL, + `server_remote_host` varchar(255) default NULL, `server_remote_port` varchar(16) default NULL, `state` varchar(15) default 'unpublished', `text` text, @@ -48,7 +48,7 @@ class comment_installer { module::set_var("comment", "spam_caught", 0); module::set_var("comment", "access_permissions", "everybody"); - module::set_version("comment", 3); + module::set_version("comment", 4); } static function upgrade($version) { @@ -62,6 +62,19 @@ class comment_installer { module::set_var("comment", "access_permissions", "everybody"); module::set_version("comment", $version = 3); } + + if ($version == 3) { + /* + 40 bytes for server_remote_addr is enough to swallow the longest + representation of an IPv6 addy. + + 255 bytes for server_remote_host is enough to swallow the longest + legit DNS entry, with a few bytes to spare. + */ + $db->query("ALTER TABLE {comments} CHANGE `server_remote_addr` `server_remote_addr` varchar(40)"); + $db->query("ALTER TABLE {comments} CHANGE `server_remote_host` `server_remote_host` varchar(255)"); + module::set_version("comment", $version = 4); + } } static function uninstall() { -- cgit v1.2.3 From c12c43a415cbbe172687f888c1ae388b7f4e4451 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 27 Mar 2011 11:38:37 -0700 Subject: A little more work on kandsten's fix for IPv6 support in 10785b1e820c5e10d982c6b49125903886f7b889: - some style cleanup - bump the module version in module.info - rebuild the installer.sql --- installer/install.sql | 6 +++--- modules/comment/helpers/comment_installer.php | 18 +++++++++--------- modules/comment/module.info | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'modules/comment/helpers') diff --git a/installer/install.sql b/installer/install.sql index 865cb2a4..77cda72b 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -67,8 +67,8 @@ CREATE TABLE {comments} ( `server_http_referer` varchar(255) DEFAULT NULL, `server_http_user_agent` varchar(128) DEFAULT NULL, `server_query_string` varchar(64) DEFAULT NULL, - `server_remote_addr` varchar(32) DEFAULT NULL, - `server_remote_host` varchar(64) DEFAULT NULL, + `server_remote_addr` varchar(40) DEFAULT NULL, + `server_remote_host` varchar(255) DEFAULT NULL, `server_remote_port` varchar(16) DEFAULT NULL, `state` varchar(15) DEFAULT 'unpublished', `text` text, @@ -246,7 +246,7 @@ CREATE TABLE {modules} ( /*!40101 SET character_set_client = @saved_cs_client */; INSERT INTO {modules} VALUES (1,1,'gallery',46,1); INSERT INTO {modules} VALUES (2,1,'user',3,2); -INSERT INTO {modules} VALUES (3,1,'comment',3,3); +INSERT INTO {modules} VALUES (3,1,'comment',4,3); INSERT INTO {modules} VALUES (4,1,'organize',4,4); INSERT INTO {modules} VALUES (5,1,'info',2,5); INSERT INTO {modules} VALUES (6,1,'rss',1,6); diff --git a/modules/comment/helpers/comment_installer.php b/modules/comment/helpers/comment_installer.php index cd20ef72..5c6bd586 100644 --- a/modules/comment/helpers/comment_installer.php +++ b/modules/comment/helpers/comment_installer.php @@ -64,15 +64,15 @@ class comment_installer { } if ($version == 3) { - /* - 40 bytes for server_remote_addr is enough to swallow the longest - representation of an IPv6 addy. - - 255 bytes for server_remote_host is enough to swallow the longest - legit DNS entry, with a few bytes to spare. - */ - $db->query("ALTER TABLE {comments} CHANGE `server_remote_addr` `server_remote_addr` varchar(40)"); - $db->query("ALTER TABLE {comments} CHANGE `server_remote_host` `server_remote_host` varchar(255)"); + // 40 bytes for server_remote_addr is enough to swallow the longest + // representation of an IPv6 addy. + // + // 255 bytes for server_remote_host is enough to swallow the longest + // legit DNS entry, with a few bytes to spare. + $db->query( + "ALTER TABLE {comments} CHANGE `server_remote_addr` `server_remote_addr` varchar(40)"); + $db->query( + "ALTER TABLE {comments} CHANGE `server_remote_host` `server_remote_host` varchar(255)"); module::set_version("comment", $version = 4); } } diff --git a/modules/comment/module.info b/modules/comment/module.info index cd34f140..e5aa454d 100644 --- a/modules/comment/module.info +++ b/modules/comment/module.info @@ -1,3 +1,3 @@ name = "Comments" description = "Allows users and guests to leave comments on photos and albums." -version = 3 +version = 4 -- cgit v1.2.3