diff options
author | Koosha Khajeh Moogahi <koosha.khajeh@gmail.com> | 2012-08-18 19:06:44 +0200 |
---|---|---|
committer | Frédéric Buclin <LpSolit@gmail.com> | 2012-08-18 19:06:44 +0200 |
commit | c6c54c2e4235783544c44c08e4e55d4057556588 (patch) | |
tree | 2014f444a3de707c4aa47ddbd29aa77347c54500 /Bugzilla/Install/DB.pm | |
parent | ca3d59070b8e470c3c82399f62e8b801db043e89 (diff) | |
download | bugs-c6c54c2e4235783544c44c08e4e55d4057556588.tar bugs-c6c54c2e4235783544c44c08e4e55d4057556588.tar.gz bugs-c6c54c2e4235783544c44c08e4e55d4057556588.tar.bz2 bugs-c6c54c2e4235783544c44c08e4e55d4057556588.tar.xz bugs-c6c54c2e4235783544c44c08e4e55d4057556588.zip |
Bug 187753: Specify a maximum length for quips (512 characters)
r/a=LpSolit
Diffstat (limited to 'Bugzilla/Install/DB.pm')
-rw-r--r-- | Bugzilla/Install/DB.pm | 25 |
1 files changed, 23 insertions, 2 deletions
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__ |