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

Unchecked checkboxes are not serialised #74

Closed
Eldblom opened this Issue Oct 30, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@Eldblom
Copy link
Contributor

Eldblom commented Oct 30, 2015

When checkboxes is default checked, unchecking it on an item, the value 0 (zero) is not serialised.

To recreate:

  1. Create a checkbox field on a template
  2. Set the standard value for the field to checked.
  3. Create an item based on the template
  4. Uncheck the checkbox
  5. Do a clean install
  6. Sync the item back
  7. Check that the checkbox field is checked
@kamsar

This comment has been minimized.

Copy link
Collaborator

kamsar commented Oct 30, 2015

Good catch, I think this can be fixed with a field formatter to override the way checkboxes are stored.

@kamsar

This comment has been minimized.

Copy link
Collaborator

kamsar commented Oct 31, 2015

Implementation notes:

  • On reflection a field formatter is not a correct solution as checkboxes are not the only case where standard values could result in significant blank values (e.g. a text field could also have a blank value overriding a standard value). We need to alter the way ItemData parses fields to grab fields both using standard values and not using standard values (right now it gets them without only), then return explicit blanks for fields which have a standard value but their value without the standard value differs. Note that we have to avoid using field.IsStandardValue because that does not use cache and is ungodly slow. I'm pretty sure that if ItemData returns a field with a blank value, it'll make it into YAML.
  • Does setting an empty value in YAML cause the deserializer to consider it significant and set the field to blank? Probably. If so, can get away without needing a property to signify an important empty value.

kamsar added a commit that referenced this issue Nov 4, 2015

Alter handling of fields to support resetting fields to standard values
Fixes #74

Wraps item data passed to Rainbow in a wrapper that removes all fields marked as 'RemoveField' by the ItemChanges passed to the data provider.
This is the only indication Sitecore gives us that the save intends to reset standard value; the item in the changes will still claim the field is NOT a standard value (until after the save is complete)
@kamsar

This comment has been minimized.

Copy link
Collaborator

kamsar commented Nov 4, 2015

@Eldblom thanks for finding this. I believe I've fixed the problem in a way that solves it for all field types, not just checkboxes - vetted both by tests and comparing a whole serialized copy of the core db which included several items that were affected by this bug. I'll release a new version of Unicorn soon that will include this fix.

kamsar added a commit to SitecoreUnicorn/Rainbow that referenced this issue Nov 4, 2015

1.0.1
## IMPROVEMENTS
- The new `Rainbow.SFS.ExtraInvalidFilenameCharacters` setting enables adding additional characters to Rainbow's invalid file name character list, other than Windows' disallowed characters. This enables TFS users to successfully serialize branch templates, which have item names that begin in `$`, a reserved character by TFS. The `Rainbow.TFS.config.example` file is now shipped with Rainbow to illustrate its usage for TFS.
- When calling the SFS `MoveOrRename()` method, it is no longer required to have correct paths for all recursive children of the item being moved. The method internally corrects all child paths. Previously this was handled in Unicorn, but moving it to Rainbow makes it significantly easier to use the Rainbow APIs.

## FIXES:
- **CRITICAL** Fixes serialization of significant empty field values, such as unchecked checkboxes when the standard value is checked. (SitecoreUnicorn/Unicorn#74)
- Fixes occasional 'Directory not empty' errors when reserializing a tree of items
@Eldblom

This comment has been minimized.

Copy link
Contributor

Eldblom commented Nov 4, 2015

Great. Looking forward to the release

On 4 Nov 2015, at 1:37 PM, Kam Figy notifications@github.com wrote:

@Eldblom thanks for finding this. I believe I've fixed the problem in a way that solves it for all field types, not just checkboxes - vetted both by tests and comparing a whole serialized copy of the core db which included several items that were affected by this bug. I'll release a new version of Unicorn soon that will include this fix.


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment