diff options
author | mkanat%bugzilla.org <> | 2008-01-28 07:54:58 +0100 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2008-01-28 07:54:58 +0100 |
commit | 80aa5e83cb34a4b9ad0ef31cac749aa9dcf6d791 (patch) | |
tree | 28534a988ae23750a353458baa3e6bce8d4c6aee /Bugzilla/Install | |
parent | c87cca60cfe149bf4ffe7ed1746189b936e87bac (diff) | |
download | bugzilla-80aa5e83cb34a4b9ad0ef31cac749aa9dcf6d791.tar.gz bugzilla-80aa5e83cb34a4b9ad0ef31cac749aa9dcf6d791.tar.xz |
Bug 414012: Include the table id in fields that fail their new max-length check.
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=justdave, a=justdave
Diffstat (limited to 'Bugzilla/Install')
-rw-r--r-- | Bugzilla/Install/DB.pm | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index e9ce742d8..6b8a6fdc6 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -516,7 +516,7 @@ sub update_table_definitions { _make_lang_setting_dynamic(); # 2007-11-29 xiaoou.wu@oracle.com - Bug 153129 - change_text_types(); + _change_text_types(); # 2007-09-09 LpSolit@gmail.com - Bug 99215 _fix_attachment_modification_date(); @@ -2937,12 +2937,12 @@ sub _fix_attachment_modification_date { [qw(modification_time)]); } -sub change_text_types { +sub _change_text_types { my $dbh = Bugzilla->dbh; return if $dbh->bz_column_info('series', 'query')->{TYPE} eq 'LONGTEXT'; - _check_content_length('attachments', 'mimetype', 255); - _check_content_length('fielddefs', 'description', 255); - _check_content_length('attachments', 'description', 255); + _check_content_length('attachments', 'mimetype', 255, 'attach_id'); + _check_content_length('fielddefs', 'description', 255, 'id'); + _check_content_length('attachments', 'description', 255, 'attach_id'); $dbh->bz_alter_column('bugs', 'bug_file_loc', { TYPE => 'MEDIUMTEXT'}); @@ -2968,28 +2968,27 @@ sub change_text_types { } sub _check_content_length { - my ($table_name, $field_name, $max_length) = @_; + my ($table_name, $field_name, $max_length, $id_field) = @_; my $dbh = Bugzilla->dbh; - my $contents = $dbh->selectcol_arrayref( - "SELECT $field_name FROM $table_name - WHERE LENGTH($field_name) > ?", undef, $max_length); + my %contents = @{ $dbh->selectcol_arrayref( + "SELECT $id_field, $field_name FROM $table_name + WHERE LENGTH($field_name) > ?", {Columns=>[1,2]}, $max_length) }; - if (@$contents) { - my @trimmed; - foreach my $item (@$contents) { + if (scalar keys %contents) { + print install_string('install_data_too_long', + { column => $field_name, + id_column => $id_field, + table => $table_name, + max_length => $max_length }); + foreach my $id (keys %contents) { + my $string = $contents{$id}; # Don't dump the whole string--it could be 16MB. - if (length($item) > 80) { - push(@trimmed, substr($item, 0, 30) . "..." - . substr($item, -30) . "\n"); - } else { - push(@trimmed, $item); + if (length($string) > 80) { + $string = substr($string, 0, 30) . "..." + . substr($string, -30) . "\n"; } + print "$id: $string\n"; } - print install_string('install_data_too_long', - { column => $field_name, - table => $table_name, - max_length => $max_length, - data => join("\n", @trimmed) }); exit 3; } } |