Closed (fixed)
Project:
Drupal core
Version:
8.1.x-dev
Component:
mysql db driver
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 Mar 2014 at 14:21 UTC
Updated:
17 Aug 2016 at 00:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dave reidPatch against D7 without a test.
Comment #2
dave reidConfirmed this does also affect Drupal 8. I'm not sure at all where to start writing tests for the mysql schema class...
Comment #3
Crell commentedAnd this is why calling globals inside objects is bad. :-) Thanks, Dave!
Comment #4
webchickNo tests.
Comment #5
superspring commentedSame D8 patch with a test added.
Comment #7
superspring commentedThat'll teach me for just copying existing tests and editing.
Comment #8
superspring commentedComment #10
Jalandhar commentedUpdating the clean patch with reroll. Please review.
Comment #11
penyaskitoLooks quite good, however:
I would assert that those prefixes are the expected ones. That they are different probably is enough info for assuring this bug is gone, but this way we could avoid different bugs in the future.
Also, it would be awesome to upload a patch with only the test assuring that it test the actual bug. See "Upload a test case that fails" in https://drupal.org/core-gates#testing
Comment #12
superspring commentedHere is the same patch as #12 with a little more testing and the patch with _only_ the tests to show the fault in the original code base.
Comment #16
daffie commentedAlready fixed in #2554241: mysql's Schema implementation can only provide information about the default connection..
Comment #17
dave reidExcept this issue was clear that it was a bug that also affected Drupal 7 and needed to be fixed there, while that issue was just closed.
Comment #18
daffie commented@Dave Reid: It is going to be fixed for Drupal 7 in #2311305: Schema::getPrefixInfo() return value refers to the wrong database.
Comment #19
David_Rothstein commentedLooks like both those issues should have originally been closed as duplicates of this one, but a little late for that unfortunately.
The Drupal 8 patch was committed without tests, so the Drupal 7 backport that's RTBC in the other issue doesn't have tests either. The patch here has tests, so I guess the simplest thing to do is repurpose it to be about adding the tests to both Drupal 8 and 7...
Comment #20
stefan.r commentedRe-roll
Comment #23
stefan.r commentedComment #24
fabianx commentedRTBC for the tests, a test-only patch (e.g. with the fix reverted) would be great, too.
Comment #26
stefan.r commentedComment #27
stefan.r commentedComment #29
fabianx commentedRTBC - looks good to me
Comment #30
stefan.r commentedComment #32
fabianx commentedStill RTBC
Comment #33
stefan.r commentedComment #35
chx commentedEdit: deleted.
Comment #36
chx commentedComment #37
fabianx commentedComment #39
alexpottCommitted and pushed 2c2caccd45da80ec1aecdfa8905bd7d8765b1c2f to 8.2.x and 8bf7d7c to 8.1.x. Thanks!
Setting to patch to ported until the d7 porting issue exists.
A couple of CS fixes on commit.
Comment #42
bzrudi71 commentedSeems we broke PostgreSQL as well as SQLite bot ;-)
https://dispatcher.drupalci.org/job/php7_sqlite3.8/1380/
https://dispatcher.drupalci.org/job/php7_postgres9.1/1389/
Comment #45
alexpott@bzrudi71 yep - weird this had been testing on postgres and sqlite... reverted.
Comment #46
daffie commentedThe problem that the tests for PostgreSQL and SQLite are failing is that we are testing the return array from the method \Drupal\Core\Database\Driver\mysql\Schema::getPrefixInfo(). This return array is a keyed array with info about amongst other things the database. The problem is that only for MySQL the key "database" is set and not for the other two by Drupal core supported databases. So testing for the other two databases will fail.
Comment #49
daffie commentedReady for a good review.
Comment #50
fabianx commentedLooks good to me and passes on Postgres / SQlite npw. Thanks daffie!
Comment #51
alexpottHmmm.... okay but then what code can rely on this having the database information? Why does mysql have this info and the other dbs do not?
Comment #52
daffie commentedThe database information is added because it is used in Drupal\Core\Database\Driver\mysql\Schema::buildTableNameCondition. That method can easily be rewritten so that it does not need it any more. Or we can fix it the other way around and have all getPrefixInfo method set the database information. @alexpott: What do you think is the best solution.
Comment #53
alexpott@daffie yeah I looked into it and agree with your analysis of why - I guess what we have in #46 is the right way to go because otherwise it'd be a change for the mysql implementation. It is a shame these things have got out-of-sync because it makes working with the APIs tricker than it should be.
Comment #54
alexpottCommitted and pushed 32fa9448c41f0c88e92d35cbb6265d7b7013b1b4 to 8.2.x and d34b1a2 to 8.1.x. Thanks!
Fixed on commit.
Setting to patch to ported until the d7 porting issue exists.
Comment #57
daffie commentedCreated #2772127: [D7] Calling DatabaseSchema::getPrefixInfo() on a non-default connection returns the wrong database - write tests for D7.