summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Constants.pm4
-rw-r--r--Bugzilla/DB/Schema.pm2
-rw-r--r--Bugzilla/Install/DB.pm25
3 files changed, 28 insertions, 3 deletions
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index 63242ba8a..f1141195c 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -161,6 +161,7 @@ use Memoize;
MAX_BUG_URL_LENGTH
MAX_POSSIBLE_DUPLICATES
MAX_ATTACH_FILENAME_LENGTH
+ MAX_QUIP_LENGTH
PASSWORD_DIGEST_ALGORITHM
PASSWORD_SALT_LENGTH
@@ -556,6 +557,9 @@ use constant MAX_POSSIBLE_DUPLICATES => 25;
# necessary schema changes to store longer names.
use constant MAX_ATTACH_FILENAME_LENGTH => 255;
+# Maximum length of a quip.
+use constant MAX_QUIP_LENGTH => 512;
+
# This is the name of the algorithm used to hash passwords before storing
# them in the database. This can be any string that is valid to pass to
# Perl's "Digest" module. Note that if you change this, it won't take
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index 728176684..eabee07c3 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -1484,7 +1484,7 @@ use constant ABSTRACT_SCHEMA => {
REFERENCES => {TABLE => 'profiles',
COLUMN => 'userid',
DELETE => 'SET NULL'}},
- quip => {TYPE => 'MEDIUMTEXT', NOTNULL => 1},
+ quip => {TYPE => 'varchar(512)', NOTNULL => 1},
approved => {TYPE => 'BOOLEAN', NOTNULL => 1,
DEFAULT => 'TRUE'},
],
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index 5d0f61672..e04766f24 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -697,6 +697,9 @@ sub update_table_definitions {
# 2012-08-02 dkl@mozilla.com - Bug 756953
_fix_dependencies_dupes();
+ # 2012-08-01 koosha.khajeh@gmail.com - Bug 187753
+ _shorten_long_quips();
+
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
@@ -3164,8 +3167,6 @@ sub _change_text_types {
{ TYPE => 'TINYTEXT', NOTNULL => 1 });
$dbh->bz_alter_column('groups', 'description',
{ TYPE => 'MEDIUMTEXT', NOTNULL => 1 });
- $dbh->bz_alter_column('quips', 'quip',
- { TYPE => 'MEDIUMTEXT', NOTNULL => 1 });
$dbh->bz_alter_column('namedqueries', 'query',
{ TYPE => 'LONGTEXT', NOTNULL => 1 });
@@ -3753,6 +3754,26 @@ sub _fix_dependencies_dupes {
}
}
+sub _shorten_long_quips {
+ my $dbh = Bugzilla->dbh;
+ my $quips = $dbh->selectall_arrayref("SELECT quipid, quip FROM quips
+ WHERE CHAR_LENGTH(quip) > 512");
+
+ if (@$quips) {
+ print "Shortening quips longer than 512 characters:";
+
+ my $query = $dbh->prepare("UPDATE quips SET quip = ? WHERE quipid = ?");
+
+ foreach my $quip (@$quips) {
+ my ($quipid, $quip_str) = @$quip;
+ $quip_str = substr($quip_str, 0, 509) . "...";
+ print " $quipid";
+ $query->execute($quip_str, $quipid);
+ }
+ }
+ $dbh->bz_alter_column('quips', 'quip', { TYPE => 'varchar(512)', NOTNULL => 1});
+}
+
1;
__END__