Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feed Option "setEmptyValues" incompatible with boolean false, integer 0 and float 0.0 #1329

Closed
ymilin opened this issue Jun 8, 2023 · 4 comments
Assignees
Labels

Comments

@ymilin
Copy link

ymilin commented Jun 8, 2023

Description

Due to the use of PHP empty(), the Feed Option setEmptyValues, when inactive, considers the the following values as empty:

  • (bool) false
  • (int) 0
  • (float) 0.0

I think the expected behavior for this feature is to only consider a value to be empty for empty strings and null. (If this assumption is wrong, we could at least add a note that empty values are checked with PHP's emtpy() method)

This is problematic for:

  • Lightswitch Fields that cannot be updated from true to false
  • Number Fields that cannot be updated to 0 or 0.0

Here is where the check is made in the Process class:

https://github.com/craftcms/feed-me/blob/b0c9c9e25bb021876b37e25556e157f57d417de1/src/services/Process.php#LL398C9-L408C10

I'll gladly make a PR when/if we agree on a solution.

Steps to reproduce

  1. Create a mapping with setEmptyValues = 0
  2. Process a Feed that tries to update a boolean field (craft\fields\Lightswitch) from true to false
  3. The field value is ignored because it is considered empty in craft\feedme\services\Process on line 403

Additional info

  • Craft version: 4.4.13
  • PHP version: 8.2
  • Database driver & version: MariaDB 10.5.18
  • Plugins & versions: Feed Me 5.1.3.1
@ymilin ymilin added the bug label Jun 8, 2023
@bryantAXS
Copy link

I'm running into this issue on Lightswitch fields. No way of setting true => false.

@i-just
Copy link
Contributor

i-just commented Jun 13, 2023

Hi, thanks for reporting! I raised a PR for this.

For the time being, if you use strings, the import should work as expected (e.g. "false" instead of false, "0.00" instead of 0.00)

@angrybrad
Copy link
Member

Just released 5.1.4 with a fix for this! https://github.com/craftcms/feed-me/releases/tag/5.1.4

@maxpdesign
Copy link

Hi, we are still experiencing the same problem running Craft Pro 3.8.13 and Feed Me 4.7.0. Is it possible to also apply this fix for this version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants