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

$field->toStructure() throws an exception when the field value is invalid #2046

Closed
hdodov opened this issue Aug 29, 2019 · 1 comment

Comments

@hdodov
Copy link

commented Aug 29, 2019

The error I'm getting is:

Argument 1 passed to Kirby\Cms\StructureObject::setContent() must be of the type array or null, string given, called in C:\xampp\htdocs\ikarov\kirby\src\Toolkit\Properties.php on line 138

In the debugger, I saw this came from a toStructure() call:

image

This was very tricky to debug because toStructure() is called by a plugin. When you save the default translation, the plugin syncs the structure data with all other translations. Each entry had an options field of type tags which is a comma-separated string. When I changed the blueprint of that field to structure, this error began to appear because the saved value was not a YAML-encoded structure.

To Reproduce
Steps to reproduce the behavior:

  1. Have a site.txt with arbitrary string as content.
  2. Run $site->title()->toStructure()

Expected behavior
Whenever toStructure() is called with invalid data, it should return an empty structure. Then, when the value is saved, whatever invalid value existed before would be replaced with a valid one.

Kirby Version
3.2.3

@afbora afbora referenced this issue Sep 4, 2019
2 of 4 tasks complete
@afbora afbora referenced this issue Sep 12, 2019
3 of 4 tasks complete
@bastianallgeier

This comment has been minimized.

Copy link
Contributor

commented Sep 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.