cli icon indicating copy to clipboard operation
cli copied to clipboard

Clean content command does not clean inside object fields

Open bezin opened this issue 7 months ago • 3 comments

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:

  1. 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
  1. Add content to both fields of the object field.
  2. Remove one of the fields from the blueprint.
  3. Run clean:content on 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 avatar May 23 '25 13:05 bezin

@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 avatar May 28 '25 18:05 afbora

@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).

distantnative avatar May 28 '25 18:05 distantnative

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.

afbora avatar May 28 '25 20:05 afbora