Problem/Motivation
#2500513: Upgrade path for Shortcut 7.x was rolled back because we broke Postgres. It actually turns out that there was a serious bug that was only caught because of Postgres type system. Currently the Drupal\migrate\Plugin\migrate\id_map\Sql provides methods such as lookupDestinationId() and lookupSourceID that rely on the order of the values being passed in to be the same as the order they were defined in the source and therefore the order ensureTables() created the columns in the map table.
Proposed resolution
When we have multiple source ids, enforce the caller to pass through the values in a key => pair so we can correctly apply the filter conditions.
Remaining tasks
- Check through the idMap class and make sure we're no longer relying on the order of the fields but instead the keys.
- Refactor how we apply the conditions into a method because of how often it is done throughout the class
- Refactor the migration process plugin to accept the source id key in the yaml configuration.
User interface changes
n/a
API changes
Callers to methods on the idMap will now need to provide both key and value pairs rather than just an array of values. We can/will provide backwards compatibility when querying on only one value as there can be no confusion.
Data model changes
The schema for the migration process plugin will change although we don't currently have that schema in core. The structure for the migration process plugin may also change to support key => value rather than just values.
| Comment | File | Size | Author |
|---|---|---|---|
| #32 | interdiff.txt | 8.25 KB | mikeryan |
| #32 | idmap_source_and-2571499-32.patch | 25.09 KB | mikeryan |
| #15 | 2571499-15.patch | 20.38 KB | benjy |
| #15 | interdiff.txt | 2.39 KB | benjy |
| #11 | interdiff.txt | 7.83 KB | benjy |
Comments
Comment #3
benjy commentedRe-rolled minus the shortcut migration stuff, will add some dedicated tests here although i think we're probably covered by the updated unit tests.
Comment #5
benjy commentedComment #7
phenaproximaThis is a great start, and a much more logical and developer-friendly way to look up IDs. I'm on the fence about whether we really need more test coverage (specifically, a fail patch for PostgreSQL).
Nit: No need for
$query =. Or, for that matter, the = operator in condition().Ditto.
I find this comment kind of confusing. Can it be reworded?
Ditto with
$query =and the condition operator.Comment #8
benjy commentedFixed the feedback. Also fixed getRowByDestination().
The last thing left todo here is check the interfaces and make sure all the docs are up-to-date.
Comment #11
benjy commentedFixed up some docs and also fixed deleteBulk() and deleteDestination(). deleteBulk() has some bad naming because $source_id_values can actually be an array of $source_id_values. It's also not used in core so would be good if @mikeryan could test this?
Also a re-roll.
Comment #12
phenaproximaIt looks fine to me, but I'd like @mikeryan's input for RTBC.
Comment #13
mikeryanI agree with phenaproxima, let's take the opportunity to remove the needless ", '='" in all these query conditions.
As for deleteBulk() - in D7 that was used in association with bulk deletions on rollback, it has no known use case in D8, can we remove it here? Or, should I remove it in the rollback patch?
Comment #14
andyposthttp://cgit.drupalcode.org/drupal/tree/core/modules/migrate/src/Plugin/m...
some this notaffected by patch? probably should return IDs with values
Comment #15
benjy commented@andypost getSourceIdValues() already returns key/value pairs so that use case should be fine. If it didn't work we'd have had a few fails with undefined indexes i'd expect, patch attach shows that. However, it maybe is badly named/documented but that's an existing issue..
Comment #17
phenaproximaComment #19
phenaproximaZOMG. It's a friggin' fail patch, testbot.
Comment #20
mikeryanlgtm
Comment #21
benjy commentedRe-uploading 15 because I didn't change anything in that patch from #11 that could have caused a fatal in that test. Unless something in head changed.
Comment #22
andypost@benjy
$id_map = $this->idMap->getRowBySource($this->currentSourceIds)as I pointed is not agetSourceIdValues()but protected variable that poorly documentedComment #23
benjy commentedThat protected variable is set from getSourceIdValues() just one line above with: $this->currentSourceIds = $row->getSourceIdValues(); We should update the docs, $source_id_values is used consistently used throughout the id map to reference the source ids structured as key/value pairs.
Seems the postgres issue was added to HEAD sometime between #11 and #15, will have to bisect to try and figure that out. If someone has Postgres and can help, that would be great.
Comment #24
benjy commentedJust going to try the patch that passed previously on Posgress before
Comment #25
benjy commentedThe posgres fails seem to be almost random at this point, no idea what is going on, can someone reproduce locally?
Comment #26
phenaproximaI'm thinking the same thing, frankly. Take a look at this, which was just committed by @alexpott: #2572897: Promote and sticky options migrate to empty checkboxes. Given the patch in question, those test failures make absolutely no sense.
Comment #27
benjy commentedPosgres went green on it's own it seems, can I get a RTBC?
Comment #28
phenaproximaLooks great! I love this change -- makes things MUCH easier to understand.
Comment #31
mikeryanFYI, this is breaking on the rollback support committed yesterday, working on it...
Comment #32
mikeryanWell, that was harder than it looks... Ended up changing lookupSourceID() to return a keyed array to match how the source ID arrays are being used throughout, and currentDestination (added by rollback) to do the key thing like the rest of the patch. Also changed the executable rollback() to use deleteDestination() since that's what it's there for (although it actually never worked - fixed that) instead of the silly serialized source key. And, took the liberty of removing the unused bulkDelete()...
Comment #33
benjy commentedChanges look good to me. I think the SQLite failure was unrelated and we have a green one now anyway.
Comment #34
phenaproxima@Mixologic and @catch told me on IRC that we're OK RTBCing and committing based on DrupalCI results. If @benjy is OK with the latest patch, I am too.
Comment #35
mikeryanComment #36
webchickFixed some Eg. -> e.g. usages and committed and pushed to 8.0.x. Thanks!
Comment #39
webchick