diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php index 7b6a7d8..b757420 100644 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php @@ -39,6 +39,11 @@ class Connection extends DatabaseConnection { * The maximum length of exception messages if a max_allowed_packet error * occurs. * + * We set it to 1024 bytest, because it's minimal value for database max_allowed_packet variable. + * + * @link https://mariadb.com/kb/en/mariadb/server-system-variables/#max_allowed_packet + * @link https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_max_allowed_packet + * * @var int */ const MAX_ALLOWED_PACKET_MESSAGE_LENGTH = 1024; diff --git a/core/modules/system/lib/Drupal/system/Tests/Database/LargeQueryTest.php b/core/modules/system/lib/Drupal/system/Tests/Database/LargeQueryTest.php index f005ea1..80d63c8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Database/LargeQueryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Database/LargeQueryTest.php @@ -38,7 +38,7 @@ function testMaxAllowedPacketQueryTruncating() { // Retrieve the max_allowed_packet value from the current instance and // check if PHP is configured with sufficient allowed memory to be able // to generate a query larger than max_allowed_packet. - $result = db_query("SHOW VARIABLES WHERE Variable_name = 'max_allowed_packet'")->fetchCol(1); + $result = db_query("SELECT @@global.max_allowed_packet")->fetchCol(1); $max_allowed_packet = $result[0]; if (drupal_check_memory_limit($max_allowed_packet)) { $long_name = str_repeat('ł', $max_allowed_packet); @@ -46,6 +46,7 @@ function testMaxAllowedPacketQueryTruncating() { db_query('SELECT name FROM {test} WHERE name = :name', array(':name' => $long_name)); $this->fail("An exception should be thrown for queries larger than 'max_allowed_packet'"); } catch (DatabaseException $e) { + $this->assertEqual($e->getPrevious()->errorInfo[1], 1153, "Got a packet bigger than 'max_allowed_packet' bytes exception thrown"); $this->assertEqual(strlen($e->getMessage()), \Drupal\Core\Database\Driver\mysql\Connection::MAX_ALLOWED_PACKET_MESSAGE_LENGTH, "'max_allowed_packet' exception message truncated"); } }