Currently in 7.x-2.x, I can not pass a default value of zero.

In migration::applyMappings near line 813, there's a test for $source and $default values.

        // When updating existing items, make sure we don't create a destination
        // field that is not mapped to anything (a source field or a default value)
        if (!$source && !$default) {
          continue;
        }

This is a bit harsh because I may want a default value of zero to be set for a field. For example, pathauto may be enabled on my site but my initial migration of nodes are going to keep their original paths. I want to make sure that $entity->pathauto is properly set to 0 (zero). The current test will skip setting pathauto completely because !$default is true when $default = 0.

The attached patch attempts to fix this issue.

CommentFileSizeAuthor
migrate-allow-zero-default-value.patch562 bytesrobeano

Comments

mikeryan’s picture

Status: Active » Fixed

Strange, I have an environment where setting the pathauto defaultValue seems to work, but I can reproduce this... Anyway, isset() works just fine, committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.