Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The method Drupal\Core\Database\Driver\mysql\Connection::__construct() cannot be called without the second parameter being set. We have in the method the following code:
if (stripos($connection_options['init_commands']['sql_mode'], $mode) !== FALSE) {
Were $connection_options is the second parameter. If it is not set the following error is given: "TypeError: stripos(): Argument #1 ($haystack) must be of type string, array given".
Proposed resolution
The value of $connection_options['init_commands']['sql_mode']
needs to be set.
Remaining tasks
TBD
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
TBD
Comment | File | Size | Author |
---|---|---|---|
#25 | interdiff_24_25.txt | 735 bytes | gidarai |
#25 | 3251084-25-test-only-should-fail.patch | 942 bytes | gidarai |
#25 | 3251084-25.patch | 2.5 KB | gidarai |
|
Issue fork drupal-3251084
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
daffie CreditAttribution: daffie commentedThe code that created the problem was added in #3218978: MySQL driver allows settings.php to remove ANSI_QUOTES from sql_mode, but doesn't work when it is. That code is present in D9.2 and D9.3. Nobody has complained about it, therefor keeping the priority on "normal".
Comment #3
mondrake#3129043: Move core database drivers to modules of their own landed.
Comment #4
beatrizrodriguesWill work on that :)
Comment #6
beatrizrodriguesI did a MR. Hope it fits. Leaving in NW because still needs issue summary update
Comment #7
daffie CreditAttribution: daffie commentedThere is an unresolved thread on the MR.
Comment #8
beatrizrodriguesThanks @daffie I think know the right solution is implemented.
Comment #9
daffie CreditAttribution: daffie commentedThe fix is good. Now we need only a test.
Comment #10
daffie CreditAttribution: daffie commentedComment #11
joachim CreditAttribution: joachim as a volunteer commentedFor a test, simply remove the 2nd parameter in testDeprecationConnection() -- it's only here as a workaround for this bug:
Comment #13
mr.baileysThank you @joachim, I updated
\Drupal\KernelTests\Core\Database\MysqlDriverLegacyTest::testDeprecationConnection()
and removed the code that was in place to work around the bug being fixed in this issue.Comment #14
joachim CreditAttribution: joachim at Factorial GmbH commentedLGTM!
Comment #15
alexpottAdded a comment to the MR that needs work.
Comment #17
Tauany Bueno CreditAttribution: Tauany Bueno at CI&T commentedhi! i'll work on this :)
Comment #18
Tauany Bueno CreditAttribution: Tauany Bueno at CI&T commentedHello!
I fixed the issues pointed out regarding ANSI_QUOTES and the if inside the foreach.
Since I'm new to Drupal, if this doesn't fix the problem I'd be more than happy to learn other solutions and approaches to the issue :)
Changing the status to needs review.
Comment #19
RenatoCostaDev CreditAttribution: RenatoCostaDev at CI&T commented"I'm reviewing this issue"
Comment #20
RenatoCostaDev CreditAttribution: RenatoCostaDev at CI&T commentedI saw it and seems right to me.
Comment #21
catchLeft a question on the MR
Comment #22
daffie CreditAttribution: daffie commentedNeeds work for the 2 unresolved threads on the MR.
Comment #24
gidarai CreditAttribution: gidarai at Finalist commentedCreated test and rerolled old code changes.
I submitted 2 patches, one with only the test file where the test will fail and another patch with the actual fix where the test succeeds.
Please review.
Comment #25
gidarai CreditAttribution: gidarai at Finalist commentedAfter review on local-machine from daffie i have made some changes and also have fixed the corrupt patch that failed to apply.
Comment #27
daffie CreditAttribution: daffie at Finalist commentedBoth the fix and the added test look good to me.
For me it is RTBC.
Comment #28
catchLooks like we still need this follow-up suggested by @alexpott:
Comment #29
daffie CreditAttribution: daffie at Finalist commentedI think that will be fixed in #3261236: ANSI and TRADITIONAL SQL mode implementations vary between mysql and mariadb.
Comment #31
catchAhh thanks for finding the existing issue.
Committed 1b7265e and pushed to 10.1.x. Thanks!