diff --git a/core/modules/dblog/dblog.install b/core/modules/dblog/dblog.install index b3164051b8..e646283ff6 100644 --- a/core/modules/dblog/dblog.install +++ b/core/modules/dblog/dblog.install @@ -15,6 +15,7 @@ function dblog_schema() { 'wid' => [ 'type' => 'serial', 'not null' => TRUE, + 'size' => 'big', 'description' => 'Primary Key: Unique watchdog event ID.', ], 'uid' => [ diff --git a/core/modules/dblog/tests/src/Kernel/DbLogTest.php b/core/modules/dblog/tests/src/Kernel/DbLogTest.php index 7900d624bb..47ac1870b1 100644 --- a/core/modules/dblog/tests/src/Kernel/DbLogTest.php +++ b/core/modules/dblog/tests/src/Kernel/DbLogTest.php @@ -3,7 +3,10 @@ namespace Drupal\Tests\dblog\Kernel; use Drupal\Component\Render\FormattableMarkup; +use Drupal\Core\Database\Connection; use Drupal\Core\Database\Database; +use Drupal\Core\Database\Query\Insert; +use Drupal\dblog\Logger\DbLog; use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\dblog\Functional\FakeLogEntries; @@ -56,6 +59,50 @@ public function testDbLogCron() { } /** + * Tests that the log entry ID can be a big integer. + */ + public function testLogEntryIdIntegerOverflow() { + $insert = Database::getConnection()->insert('watchdog'); + + $connection = $this->prophesize(Connection::class); + $connection->getTarget()->willReturn(DbLog::DEDICATED_DBLOG_CONNECTION_TARGET); + $connection->insert('watchdog')->willReturn(new class ($insert) { + + /** + * The decorated query object. + * + * @var \Drupal\Core\Database\Query\Insert + */ + private $decorated; + + /** + * Constructor for this anonymous class. + * + * @param \Drupal\Core\Database\Query\Insert $decorated + * The decorated query object. + */ + public function __construct(Insert $decorated) { + $this->decorated = $decorated; + } + + /** + * Overrides \Drupal\Core\Database\Query\Insert::fields(). + * + * Purposefully sets the 'wid' column of the query to a value which will + * overflow the normal integer limit. + */ + public function fields(array $fields, array $values = []) { + $fields['wid'] = strval(PHP_INT_MAX) . '0'; + return $this->decorated->fields($fields, $values); + } + + }); + $this->container->set('database', $connection->reveal()); + $this->generateLogEntries(1); + $this->assertTrue(TRUE); + } + + /** * Runs cron and returns number of new log entries. * * @return int