]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 141951: Set the max_packet_size for attachments (and bugs_fulltext) when connecti...
authormkanat%bugzilla.org <>
Tue, 28 Oct 2008 06:02:15 +0000 (06:02 +0000)
committermkanat%bugzilla.org <>
Tue, 28 Oct 2008 06:02:15 +0000 (06:02 +0000)
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=mkanat

Bugzilla/Bug.pm
Bugzilla/Constants.pm
Bugzilla/DB/Mysql.pm
docs/en/xml/installation.xml

index c128d693e51a99495957ae2f00d798af58d58a1e..6961a1c5b866ec32498dece673ed3ea8f2c68d28 100644 (file)
@@ -223,9 +223,6 @@ use constant UPDATE_COMMENT_COLUMNS => qw(
 # activity table.
 use constant MAX_LINE_LENGTH => 254;
 
-# Used in _check_comment(). Gives the max length allowed for a comment.
-use constant MAX_COMMENT_LENGTH => 65535;
-
 use constant SPECIAL_STATUS_WORKFLOW_ACTIONS => qw(
     none
     duplicate
index 7282800043e9a2f7bdf29fc26f20bd5cdba01abe..0aa8d74cab29f2650a60dc3b39414e42af3fa1ae 100644 (file)
@@ -84,6 +84,7 @@ use File::Basename;
     LIST_OF_BUGS
 
     COMMENT_COLS
+    MAX_COMMENT_LENGTH
 
     CMT_NORMAL
     CMT_DUPE_OF
@@ -260,6 +261,8 @@ use constant LIST_OF_BUGS => 1;
 
 # The column length for displayed (and wrapped) bug comments.
 use constant COMMENT_COLS => 80;
+# Used in _check_comment(). Gives the max length allowed for a comment.
+use constant MAX_COMMENT_LENGTH => 65535;
 
 # The type of bug comments.
 use constant CMT_NORMAL => 0;
index 0a85fe26429a079e9aaef0c77a8910fd504dd474..c01fc2a270a490bfaac1a7b8e9cb79e85a87d51b 100644 (file)
@@ -48,6 +48,11 @@ use Bugzilla::Util;
 use Bugzilla::Error;
 use Bugzilla::DB::Schema::Mysql;
 
+# This is how many comments of MAX_COMMENT_LENGTH we expect on a single bug.
+# In reality, you could have a LOT more comments than this, because 
+# MAX_COMMENT_LENGTH is big.
+use constant MAX_COMMENTS => 50;
+
 # This module extends the DB interface via inheritance
 use base qw(Bugzilla::DB);
 
@@ -90,6 +95,19 @@ sub new {
         }
     }
 
+    # The "comments" field of the bugs_fulltext table could easily exceed
+    # MySQL's default max_allowed_packet. Also, MySQL should never have
+    # a max_allowed_packet smaller than our max_attachment_size. However,
+    # if we've already set a max_allowed_packet in MySQL bigger than all
+    # of those, we should keep it.
+    my (undef, $current_max_allowed) = $self->selectrow_array(
+        q{SHOW VARIABLES LIKE 'max\_allowed\_packet'});
+    my $min_max_allowed_packet = MAX_COMMENTS * MAX_COMMENT_LENGTH;
+    my $max_allowed_packet = max($min_max_allowed_packet,
+                                 $current_max_allowed,
+                                 Bugzilla->params->{'maxattachmentsize'});
+    $self->do("SET SESSION max_allowed_packet = $max_allowed_packet");
+
     return $self;
 }
 
index a57c96735b6d473a340cbdad2c9b406b9f25347a..62b3bbb34f444435f23596f4975137f7dac157c3 100644 (file)
@@ -1,5 +1,5 @@
 <!-- <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"> -->
-<!-- $Id: installation.xml,v 1.157.2.3 2008/09/18 22:33:33 lpsolit%gmail.com Exp $ -->
+<!-- $Id: installation.xml,v 1.157.2.4 2008/10/28 01:02:17 mkanat%bugzilla.org Exp $ -->
 <chapter id="installing-bugzilla">
   <title>Installing Bugzilla</title>
 
           </para>
         </caution>
         
-        <section id="install-setupdatabase">
-          <title>Allow large attachments</title>
-        
-          <para>
-            By default, MySQL will only accept packets up to 64Kb in size.
-            If you want to have attachments larger than this, you will need
-            to modify your <filename>/etc/my.cnf</filename> as below.
-          </para>
-
-          <screen>  [mysqld]
-  # Allow packets up to 1M
-  max_allowed_packet=1M</screen>
-
-          <para>
-            There is also a parameter in Bugzilla called 'maxattachmentsize'
-            (default = 1000 Kb) that controls the maximum allowable attachment
-            size. Attachments larger than <emphasis>either</emphasis> the 
-            'max_allowed_packet' or 'maxattachmentsize' value will not be
-            accepted by Bugzilla.
-          </para>
-
-          <note>
-            <para>
-              This does not affect Big Files, attachments that are stored directly
-              on disk instead of in the database.  Their maximum size is
-              controlled using the 'maxlocalattachment' parameter.
-            </para>
-          </note>
-        </section>
-        
         <section>
           <title>Allow small words in full-text indexes</title>