Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
migration system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Aug 2015 at 04:18 UTC
Updated:
16 Sep 2015 at 17:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mikeryanWell, the underlying issue is that MigrateSqlSource in the absence of an explicit database connection defaults to a hard-coded 'migrate' connection, which is a bad thing - connections should really always be explicit. #2552791: MigrateSqlSource should use dependency injection proposes refactoring this whole business, but I'd be happy to at least for the moment remove the 'migrate' default.
Comment #3
neclimdulI think the code might not have been clear leading to some confusion. The patch just wraps the current code to stash the original migrate connection and then recover it during tearDown. The code is actually stolen from TestBase where it does the same thing for the default connection.
Not really visible in the patch is the logic where we copy the default connection and change the prefix to give the source database its own separate "database" which doesn't need to change to fix this bug.
I'm told there are other issues to handle passing connections better which may allow this whole thing to be replaced with some cleaner code in the future that doesn't muck with the global Database statics but this fixes the problem for now (and helps me bounce between testing automated and manual testing a lot easier).
Comment #4
neclimdulchanged the order of the methods so its easier to review and added a @todo pointing to the DI issue.
Comment #5
phenaproximaI have nits but overall this looks good. It's unfortunate that we need it, but a necessary evil.
Nit: URL should be on a new line.
Should be protected.
Nit: There's an extra line here.
"Broken test?" isn't terribly informative. Can this phrase either be made more useful or removed entirely?
Please add a @see createMigrationConnection() comment.
This should also mention the DI issue.
protected
Comment #6
phenaproximaComment #7
neclimdul1) Bah, storm doesn't handle multiline todo's so the link looks unrelated. I made it short enough to fit under 80 but now I don't think it makes as much sense. ok?
2,7) That was intentional. Calling it in child classes would break assumptions about how its called. (overwrite the original connection) TestBase does this as well.
3) It took me 20min to find this... empty lines where required at the top of methods when I started in Drupal... oh the times, the are a changing.
4) Taken from Simpletest's TestBase(along with this entire code block incidentally)
5) Its the only real line in the method. I think its pretty clear the connection and it isn't allowed with the @inheritdoc.
6) done
Comment #8
phenaproximaI keep trying to find new ways to say "RTBC", so I made this: http://i.imgur.com/AE0xTi2.jpg
Comment #9
benjy commentedI'd rather use protected than private.
Comment #10
neclimdulSo, we actually want this private because being protected means child classes can call it which could lead to accidentally overwriting the previous connection. Simpletests run in separate processes so this shouldn't have a big effect but it could lead to some weird problems.
Comment #11
webchickMakes sense to me.
Committed and pushed to 8.0.x. Thanks!