The createDuplicate() method in it's current form won't work as it just returns the array from the Exporter::import() method, this also needs to be passed to create() to actually construct the Exportable object.
Whilst looking at this, I also realised that the current logic for dealing with serialized fields won't work. We could be loading a serialized string from the database, or the data array could be from import, in which case the any serialized arrays would already be constructed. So we need to check if it is a string, but also that it isn't an empty string.
This will need some tests to check that the duplicated exportable is the same. Which could be more difficult to compare; for example, if a duplicate object is created from a default, isInCode() will not be set, so we will need to bear this in mind for the tests.
Comment | File | Size | Author |
---|---|---|---|
#1 | ctools-exportable-create-duplicate-fix.patch | 2.21 KB | damiankloip |
Comments
Comment #1
damiankloip CreditAttribution: damiankloip commentedComment #2
damiankloip CreditAttribution: damiankloip commentedInstead of just checking if the serialized string is empty we could try to unserialize and see if we have a result, if not, then use the string?
Comment #3
damiankloip CreditAttribution: damiankloip commented.
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedThis looks good to me.
Comment #5
damiankloip CreditAttribution: damiankloip commentedRTBC good? :)
Comment #6
dawehnerLooks fine for me as well
Comment #7
damiankloip CreditAttribution: damiankloip commentedOk, thanks!
Comment #8
tim.plunkettCommitted!
http://drupalcode.org/project/ctools.git/commit/6e69d51
Comment #9
damiankloip CreditAttribution: damiankloip commentedThanks!