From d7447bf95827d7e9da681d496a192fffbc2810a4 Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Wed, 10 May 2006 22:49:29 +0000 Subject: Bug 96431: It's possible to write an essay in the Summary field. Patch By Max Kanat-Alexander r=LpSolit, a=myk --- Bugzilla/DB/Schema.pm | 2 +- checksetup.pl | 46 +++++++++++++++++++++- .../en/default/bug/create/create-guided.html.tmpl | 3 +- template/en/default/bug/create/create.html.tmpl | 3 +- template/en/default/bug/edit.html.tmpl | 3 +- 5 files changed, 51 insertions(+), 6 deletions(-) diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm index 16b5320d6..f02f2d1af 100644 --- a/Bugzilla/DB/Schema.pm +++ b/Bugzilla/DB/Schema.pm @@ -167,7 +167,7 @@ use constant ABSTRACT_SCHEMA => { bug_status => {TYPE => 'varchar(64)', NOTNULL => 1}, creation_ts => {TYPE => 'DATETIME'}, delta_ts => {TYPE => 'DATETIME', NOTNULL => 1}, - short_desc => {TYPE => 'MEDIUMTEXT', NOTNULL => 1}, + short_desc => {TYPE => 'varchar(255)', NOTNULL => 1}, op_sys => {TYPE => 'varchar(64)', NOTNULL => 1}, priority => {TYPE => 'varchar(64)', NOTNULL => 1}, product_id => {TYPE => 'INT2', NOTNULL => 1}, diff --git a/checksetup.pl b/checksetup.pl index c3b719c4c..4a059f1c7 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -3781,8 +3781,10 @@ if ($dbh->bz_column_info('votes', 'count')) { } # 2004/02/15 - Summaries shouldn't be null - see bug 220232 -$dbh->bz_alter_column('bugs', 'short_desc', - {TYPE => 'MEDIUMTEXT', NOTNULL => 1}, ''); +if (!exists $dbh->bz_column_info('bugs', 'short_desc')->{NOTNULL}) { + $dbh->bz_alter_column('bugs', 'short_desc', + {TYPE => 'MEDIUMTEXT', NOTNULL => 1}, ''); +} # 2003-10-24 - alt@sonic.net, bug 224208 # Support classification level @@ -4293,6 +4295,46 @@ if ($dbh->bz_column_info('flags', 'id')->{'TYPE'} eq 'INT3') { $dbh->bz_drop_column('flags', 'is_active'); } +# short_desc should not be a mediumtext, fix anything longer than 255 chars. +if($dbh->bz_column_info('bugs', 'short_desc')->{TYPE} eq 'MEDIUMTEXT') { + # Move extremely long summarries into a comment ("from" the Reporter), + # and then truncate the summary. + my $long_summary_bugs = $dbh->selectall_arrayref( + 'SELECT bug_id, short_desc, reporter + FROM bugs WHERE LENGTH(short_desc) > 255'); + + if (@$long_summary_bugs) { + print <prepare( + 'INSERT INTO longdescs (bug_id, who, thetext, bug_when) + VALUES (?, ?, ?, NOW())'); + my $desc_sth = $dbh->prepare('UPDATE bugs SET short_desc = ? + WHERE bug_id = ?'); + my @affected_bugs; + foreach my $bug (@$long_summary_bugs) { + my ($bug_id, $summary, $reporter_id) = @$bug; + my $summary_comment = "The original summary for this bug" + . " was longer than 255 characters, and so it was truncated" + . " when Bugzilla was upgraded. The original summary was:" + . "\n\n$summary"; + $comment_sth->execute($bug_id, $reporter_id, $summary_comment); + my $short_summary = substr($summary, 0, 252) . "..."; + $desc_sth->execute($short_summary, $bug_id); + push(@affected_bugs, $bug_id); + } + print join(', ', @affected_bugs) . "\n\n"; + } + + $dbh->bz_alter_column('bugs', 'short_desc', {TYPE => 'varchar(255)', + NOTNULL => 1}); +} + + # If you had to change the --TABLE-- definition in any way, then add your # differential change code *** A B O V E *** this comment. # diff --git a/template/en/default/bug/create/create-guided.html.tmpl b/template/en/default/bug/create/create-guided.html.tmpl index b8f1d9fd9..1e41c07ef 100644 --- a/template/en/default/bug/create/create-guided.html.tmpl +++ b/template/en/default/bug/create/create-guided.html.tmpl @@ -310,7 +310,8 @@ function PutDescription() { Summary - +

A sentence which summarises the problem. Please be descriptive and use lots of keywords. diff --git a/template/en/default/bug/create/create.html.tmpl b/template/en/default/bug/create/create.html.tmpl index ed84f3391..ca400d31c 100644 --- a/template/en/default/bug/create/create.html.tmpl +++ b/template/en/default/bug/create/create.html.tmpl @@ -301,7 +301,8 @@ function set_assign_to() { Summary: - + diff --git a/template/en/default/bug/edit.html.tmpl b/template/en/default/bug/edit.html.tmpl index 51f4223f3..adbccd141 100644 --- a/template/en/default/bug/edit.html.tmpl +++ b/template/en/default/bug/edit.html.tmpl @@ -374,7 +374,8 @@ + value="[% bug.short_desc FILTER html %]" size="60" + maxlength="255"> -- cgit v1.2.3-24-g4f1b