Clean content command does not clean inside object fields
Hello all,
first of all thanks for the CLI and specifically the clean:content command. I use it regularly durcing development. I noticed, that it does not clean inside object fields – and probably also not inside structure fields, though I did not test this.
To recreate:
- Add an object field to a blueprint, e.g. inside an page blueprint:
type: object
label:
en: Project Details
de: Projektdetails
fields:
services:
label:
en: Services
de: Leistungen
type: tags
icon: tag
width: 1/2
city:
label:
en: City
de: Stadt
type: text
icon: pin
width: 1/2
- Add content to both fields of the object field.
- Remove one of the fields from the blueprint.
- Run
clean:contenton the cli.
The content you removed is still stored inside the object field. I would expect it to be removed, too, as inside an object field are also just fields? Maybe there are side-effects I do not see at the moment, but it would be great if you could consider implementing this. During development object blueprints change as regularly as the general blueprints, so that would be really handy to clean up the mess :-)
Best Benedict
@bezin I've tested on 5.0.0-rc2 and seems works great. Do you have an custom env or which Kirby version do you use?
@afbora I would assume this is about nested fields. And just looking at the code, I think we do not support that currently but only compare whether a field exist on the top level or not, but do not apply the same to subfields of a field (that might not exist anymore).
Oh I got it. Thanks @distantnative
For ex: I've a text field in object field. If delete the text field from object field, Text field content value in object field still remains when I run the clean:content. Yes, this will not work. Maybe we can recursive loop for structure and object fields, not sure for blocks field.