Follow-up to #2558047: [meta] Dealing with conditions during migration (messaging/exceptions) is confusing and inconsistent
Problem/Motivation
Right now we have the confusing situation where a prepareRow() implementation wanting to save any per-row messages needs to call queueMessage(), whereas in process or destination plugins you would use queueMessage(). This is a historical WTF from Migrate 2 - we want to clear any pre-existing messages for each row before adding any for the current run, but the clear was done after prepareRow() is called, so it couldn't safely add messages directly without immediately losing them. The queueMessage() API was added to allow this - messages generated by prepareRow() were queued, then added to the map after the clear. Let's clean this up - clear the messages before prepareRow(), and dump the whole queue business. Ideally, we can come up with a solution that does not require the source plugin to have direct knowledge of the migration or executable classes, and make one small step towards #2543552: Modernize migration source plugins.
Proposed resolution
TBD
Remaining tasks
TBD
User interface changes
N/A
API changes
Removal of queueMessage().
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | manage_per_row_messages-2567571-15.patch | 796 bytes | mikeryan |
| #7 | manage_per_row_messages-2567571-7.patch | 8.33 KB | mikeryan |
Comments
Comment #2
mikeryanOoh, this will let us finally close #2443617: Find a way for SourcePluginBase to get MigrateExecutable...
Comment #3
mikeryanSimply moving the message clear to next() before calling prepareRow() (from prepareRow() after the prepare_row hooks) enables us to dump a bunch of unnecessary crap, in particular decoupling the source plugin from the executable. One outstanding issue - I had to remove a unit test case checking that the clear (ID map delete) is called, from testImportWithValidRowNoDestinationValues(), because the mocked source plugin mocks rewind() preventing that code path from executing. Need to figure out a better way to test that...
Comment #4
mikeryanComment #7
mikeryanComment #8
phenaproxima@mikeryan explained on IRC that this is a DX improvement. Saving messages is now going to be done using $migration->getIdMap()->saveMessage(), which is still a bit WTFey, but at least it's consistent and more sane than queueMessage() and saveQueuedMessages(). Plus, we get to lose a bunch of LOC.
Comment #9
webchickNice diffstat. Seems like it removes a lot of unneeded complexity, rock.
Committed and pushed to 8.0.x. Thanks!
Comment #11
mikeryanChange record draft added.
Comment #12
benjy commentedI like the amount of red in this patch :) just one question
How come in the same class we have a $this->idMap and a $this->migration->getIdMap()?
They reference the same thing?
Comment #13
mikeryanYep, prepareRow() should be using $this->idMap... Is it worth a follow-up patch for that?
Comment #14
benjy commentedYeah, may as well have it right. Should be easy enough and consistency is always nice.
Comment #15
mikeryanOK, here it is.
Comment #16
phenaproxima*claps hands with glee*
Comment #19
mikeryanRestoring RTBC after testbot WTF.
Comment #20
webchickCommitted and pushed to 8.0.x. Thanks!
Comment #23
quietone commentedPublished change record.