-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
Symfony YAML handler stores non-empty empty array value #6637
Comments
For the files, pages etc. fields you should better always apply first |
We usually do that, but in this case we were using the core <?php if (
$image = $plugin->header()->or($plugin->cover())->toFile()
): ?> The fallback was never used because |
Just to make the point: it's Kirby applying |
Description
When using the Symfony YAML handler –
'yaml.handler' => 'symfony'
– Kirby will create non-empty values for empty content. Given a files field, removing all previously selected files will be stored as[]
in the content file. Using the default YAML handler will result in an empty string.Result with Symfony YAML handler:
Result with default YAML handler:
Files:
This divergent behaviour will cause issues when using
isEmpty
or methods relying on this method (likeisNotEmpty
oror
) becauseisEmpty
checks on the plain field value. So even ifisNotEmpty
will returntrue
on an object, as consecutive call totoFile()
will still result in an empty object. This is unexpected and does break templating logic.Expected behavior
Empty values should be identified correctly independent of the chosen YAML handler.
Scope
This will affect any field storing collection-like content.
To reproduce
Your setup
Kirby Version
4.4.0 RC1 but it should be the same issue ever since YAML handlers have been introduced.
PHP Version
In case this matters, it happens on PHP 8.2 for us.
The text was updated successfully, but these errors were encountered: