diff options
Diffstat (limited to 'Bugzilla/Config')
-rw-r--r-- | Bugzilla/Config/Attachment.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Config/Common.pm | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/Bugzilla/Config/Attachment.pm b/Bugzilla/Config/Attachment.pm index 2b014deda..f22c01d95 100644 --- a/Bugzilla/Config/Attachment.pm +++ b/Bugzilla/Config/Attachment.pm @@ -68,7 +68,7 @@ sub get_param_list { name => 'maxattachmentsize', type => 't', default => '1000', - checker => \&check_numeric + checker => \&check_maxattachmentsize }, # The maximum size (in bytes) for patches and non-patch attachments. diff --git a/Bugzilla/Config/Common.pm b/Bugzilla/Config/Common.pm index b6aa1a108..b285b3bc9 100644 --- a/Bugzilla/Config/Common.pm +++ b/Bugzilla/Config/Common.pm @@ -50,6 +50,7 @@ use base qw(Exporter); check_netmask check_user_verify_class check_image_converter check_mail_delivery_method check_notification check_utf8 check_bug_status check_smtp_auth check_theschwartz_available + check_maxattachmentsize ); # Checking functions for the various values @@ -313,6 +314,24 @@ sub check_mail_delivery_method { return ""; } +sub check_maxattachmentsize { + my $check = check_numeric(@_); + return $check if $check; + my $size = shift; + my $dbh = Bugzilla->dbh; + if ($dbh->isa('Bugzilla::DB::Mysql')) { + my (undef, $max_packet) = $dbh->selectrow_array( + q{SHOW VARIABLES LIKE 'max\_allowed\_packet'}); + my $byte_size = $size * 1024; + if ($max_packet < $byte_size) { + return "You asked for a maxattachmentsize of $byte_size bytes," + . " but the max_allowed_packet setting in MySQL currently" + . " only allows packets up to $max_packet bytes"; + } + } + return ""; +} + sub check_notification { my $option = shift; my @current_version = |