cms icon indicating copy to clipboard operation
cms copied to clipboard

[4.x] Update child URIs when parent slug changes

Open jacksleight opened this issue 1 year ago • 2 comments

Fixes https://github.com/statamic/cms/issues/9445

This PR implements a new listener that updates the URI index for all child pages whenever the parent page is updated.

It should probably only run if the slug has actually changed, but I'm not sure if there's a way to check that in an EntrySaved listener?

I couldn't figure out the right way or place to do the test, if you can point me in the right direction I'll add that in.

jacksleight avatar Feb 02 '24 15:02 jacksleight

Oh yeah good point. I only did it like that because I was copying the other UpdateStructuredEntryUris listener that runs for tree updates, but saveQuietly is definitely an issue.

Shall I change it?

jacksleight avatar Feb 02 '24 15:02 jacksleight

I think its okay where it is 👌

It should probably only run if the slug has actually changed, but I'm not sure if there's a way to check that in an EntrySaved listener?

There's no way at the moment, but should be once #5502 gets implemented.

jasonvarga avatar Feb 02 '24 16:02 jasonvarga

Since #5502 is pretty close to being merged, I'll mark this as a draft until we implement only doing this when the slug changes.

jasonvarga avatar Feb 23 '24 20:02 jasonvarga

Cool, will do.

jacksleight avatar Feb 23 '24 21:02 jacksleight

Once the isDirty PR is ready, use it to make sure that all of this only happens if the slug has changed.

Done

jacksleight avatar Mar 27 '24 17:03 jacksleight

Duncan was right. Not sure why I was okay with leaving it as an event. Anyway, I updated it for you.

Thanks both!

jasonvarga avatar May 08 '24 20:05 jasonvarga