Data saved in the 'function' column can be too long or have bad encoding

Created on 11 December 2018, over 5 years ago
Updated 21 June 2024, 4 days ago

Problem/Motivation

When running unit tests, simpletest saves every test method run, along with the provided data, in the simpletest.function column. This can sometimes lead to MySQL errors, as the data provided can be too long for the 'function' column (varchar, 255) or it can have bad encoding.

Example #1:

Test: Drupal\\Tests\\big_pipe\\Unit\\Render\\BigPipeResponseAttachmentsProcessorTest

Data saved in 'function column:

Drupal\Tests\big_pipe\Unit\Render\BigPipeResponseAttachmentsProcessorTest->testHtmlResponse with data set "all official attachment types, with random assigned values, even if technically not valid, to prove BigPipeResponseAttachmentsProcessor is a perfect decorator"()

Error: PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'function'

Example #2:

Test: Drupal\\Tests\\big_pipe\\Unit\\Render\\Placeholder\\BigPipeStrategyTest

Data saved in 'function column: Drupal\Tests\big_pipe\Unit\Render\Placeholder\BigPipeStrategyTest->testProcessPlaceholders with data set "_no_big_pipe absent, session, no-JS cookie present: no-JS BigPipe placeholder used for HTML placeholders — but unsafe method"()

Error: ERROR 1366 (HY000): Incorrect string value: '\xE2\x80\x94 bu...' for column 'function'

Proposed resolution

Set proper encoding on the 'function' data and truncate it if necessary, before saving it.

🐛 Bug report
Status

Needs review

Version

11.0 🔥

Component
PHPUnit 

Last updated about 8 hours ago

Created by

🇷🇴Romania stefan.butura

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024