Problem/Motivation
#1167144: Make cache backends responsible for their own storage created a regression in Drupal\Core\Database\Driver\mysql\Schema->prepareComment() that truncates schema comments improperly. Currently, substr() is being used to truncate the comments. This is a problem when quotation marks are used in the comment.
Proposed resolution
Use Unicode::truncate.
Remaining tasks
- Review and RTBC.
User interface changes
None
API changes
Original report by @ivanjaros
The watchdog table, which is defined by a dblog module in dblog_schema() function, will break the installation process due to a bug where the column definition is appended to the column's name which results in a column with type` varchar(64) NOT NULL DEFAULT '' COMMENT 'Type of log message, for example "user name.
The description of the type column is 'Type of log message, for example "user" or "page not found."'.
Exchanging the double quotes with the single quotes, "Type of log message, for example 'user' or 'page not found.'", seems to fix the problem.
PHP Version 5.4.17
DB: 5.5.34-MariaDB-log
Drupal 8 Alpha 12 installs just fine. But Alpha 13 and HEAD(4.7.2014 17:00) have this issue. I cannot confirm or deny this issue when using drush for installation ony with UI.
@pwolanin noted that it can be related to \Drupal\Core\Database\Driver\mysql\Schema::prepareComment().
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | 2297993-28.patch | 2.96 KB | marthinal |
| #28 | 2297993-28-interdiff.txt | 929 bytes | marthinal |
| #24 | 2297993-23.patch | 2.99 KB | marthinal |
| #24 | 2297993-23-only-test.patch | 2.03 KB | marthinal |
| #21 | 2297993-21.patch | 2.99 KB | marthinal |
Comments
Comment #1
catchComment #2
junedkazi commentedComment #3
cilefen commentedI just tested against HEAD with MariaDB 5.5.35 and PHP 5.4.24 but the problem does not occur. D8 is the same as D7 in the schema definition for this column but yes, prepareComment() is different in D8. The D8 version uses
substrto trim the comment to a maximum length but D7 usestruncate_utf8.I performed an informal search of core for double-quotes used inside MySQL comments and found this:
The definition in comment.install is the same as D7 but it is truncated wrongly for me in D8. So, I think we are looking at a regression in prepareComment().
Please test with this patch and see if it fixes this column in dblog and the table comment for comment_entity_statistics. If it does, we'll retitle this issue.
Comment #4
catchComment #5
alexpott#1167144: Make cache backends responsible for their own storage changed from
truncate_utf8()tosubstr- we probably should change to use Unicode::truncate()Comment #6
alexpottComment #7
cilefen commentedComment #8
cilefen commentedTitle change.
Comment #9
andyceo commentedDo we need tests here?
Comment #10
catchYes let's add tests.
Comment #11
cilefen commentedTests.
Comment #12
cilefen commentedRemoved a debugging line.
Comment #13
cilefen commentedComment #14
cilefen commentedComment #15
cilefen commentedComment #16
dawehnerCan you please upload a -FAIL test to proove that the patch solves the problem?
Do we really want to support unicodes here? Well, it is just on schema time, so it seems okay.
Comment #17
cilefen commentedComment #20
cilefen commentedComment #21
marthinal commentedRerolled
Comment #23
star-szrJust context changes in the patch, reroll looks good. And we can see the fail from the test-only patch in #17, fine that the new one doesn't apply. Thanks @marthinal!
Let's remove the double semi-colon.
Other than that looks good to me.
Comment #24
marthinal commentedThanks for reviewing @Cotsser :)
Done.
Comment #25
star-szrThanks @marthinal.
Interdiff next time, please :)
Looks good and has test coverage, RTBC!
Comment #27
catchMinor, but no need to assign this to a variable - can just use the method in the if statement directly.
Comment #28
marthinal commentedOk let's do it :)
Comment #29
star-szrLooks good, thanks @marthinal.
Comment #30
alexpottCommitted 62b9d58 and pushed to 8.0.x. Thanks!