Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Use case:
1. Install a clean Drupal 6 with CCK and ImageCache Modules.
2. Create a single node in the site.
3. Try to migrate to Drupal 8 beta 15 using "drush migrate-upgrade"
Result:
Error from ConvertTokens.php who get's a NULL parameter and throws a MigrateException.
Desired:
NULL is handled correctly.
Fix:
Convert any NULLs to empty strings, which then can be used by str_replace.
Comment | File | Size | Author |
---|---|---|---|
#12 | 2573895-12.patch | 2.27 KB | phenaproxima |
#9 | drupal-handle-NULL-in-ConvertToken-2573895-9-8.0.patch | 2.11 KB | svendecabooter |
#6 | drupal-handle-NULL-in-ConvertToken-2573895-6-8.0.patch | 817 bytes | johnstorey |
#2 | drupal-handle-NULL-in-ConvertToken-2573895-8.0.patch | 801 bytes | johnstorey |
Comments
Comment #2
johnstorey CreditAttribution: johnstorey commentedComment #3
benjy CreditAttribution: benjy at PreviousNext commentedThanks for the patch, good find. We'll need to add some tests for this, ideally a unit test may already exist otherwise we can try add one.
Also, checkout the Drupal coding standards, we always put brackets for if statements like that.
Comment #4
phenaproximaWhen using ==, an empty string ('') will resolve to NULL. This should use is_null() or ===.
Agreed with @benjy that this needs a test (I believe there is a unit test of ConvertTokens, so all you'd need is an additional assert in there) and brackets for the if statement. Otherwise, looks fine and dandy to me.
Comment #5
johnstorey CreditAttribution: johnstorey commentedI cannot seem to locate where the current ConvertTokens test exist. Can anyone give me a pointer? I'd like to wrap this up before the end of the Barcelona sprint day. Thanks!
Comment #6
johnstorey CreditAttribution: johnstorey commentedPer IRC conversation, existing tests do not exist to extend to cover this use case. My suggestion is to open a new issue to cover that.
Meanwhile, here is my re-rolled patch.
Comment #7
phenaproximaWe need to fix the tests in this issue -- the reason being that committers generally don't like to commit a bug fix that is unaccompanied by test coverage. I believe ConvertTokens already has a test, so it should be reasonably simple to add an assertion or two.
Comment #8
svendecabooterComment #9
svendecabooterThere is no ConvertTokens test yet...
Attached is a patch that adds this test, and tests for normal token conversion, as well as conversion with a NULL value.
Comment #12
phenaproximaThis oughta help :)
Comment #13
phenaproximaSince 95% of the patch is by @svendecabooter and @johnstorey, I feel OK RTBCing this. Full speed ahead!
Comment #14
webchickNit-pick, fixed on commit:
str_replace()
"the" subject
Committed and pushed to 8.0.x. Thanks!