Problem/Motivation
MigrateIdMapInterface::getRowByDestination() should always return an array based on the documentation, but the actual implementation of \Drupal\migrate\Plugin\migrate\id_map\Sql::getRowByDestination() might also return FALSE.
Proposed resolution
Ensure \Drupal\migrate\Plugin\migrate\id_map\Sql::getRowByDestination() follows the documentation and always returns an array.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | core-sql_id_map_getrowbydestination-3227549-6--complete.patch | 2.31 KB | huzooka |
| #6 | core-sql_id_map_getrowbydestination-3227549-6--test-only.patch | 1.43 KB | huzooka |
Comments
Comment #2
huzookaComment #5
huzookaHmmm... so core has a test coverage for one of its documentation violation...
Comment #6
huzookaComment #7
wim leers🤯
Might I also suggest something like
to not make any change that could break anything (i.e. adding a return type would be better, but might be seen as an API change), but would have helped pinpoint this ages ago?
Comment #9
huzookaRe #7:
We obviously cannot do that, because
\Drupal\Core\Database\StatementInterface::fetchAssoc()can returnFALSEas well.Comment #10
wim leers#7: I just mean "add that assert for the return value".
Because this could theoretically still return
NULLfor example.Comment #11
huzookaRe #10:
That is impossible.
But if the actual statement's
::fetchAssoc()method returns anything else than anarrayorFALSE, then we have to fix the actual DB statement (because its interface declares that it has to return with anarrayorFALSE).Comment #12
huzookaComment #13
huzookaRelated: #3227660: MigrateExecutable::rollback incorrectly assumes MigrateMapInterface::getRowByDestination() returns an array with 'rollback_action' key.
Comment #14
wim leersAha — all good then! I have learned to not trust the database layer 🤓, but in this case that is then unwarranted!
Sorry for derailing this over a nitpick.
This patch has explicit test coverage. It is updating code to actually do what its docs say. I can't find anything else to nitpick here.
Comment #15
huzookaComment #17
catchCommitted 8dea1fb and pushed to 9.3.x. Thanks!
Comment #18
huzookaWow, that was fast!
Thank you, @catch!
Comment #19
huzookaFixing the IS.