diff --git a/src/Entries/Entry.php b/src/Entries/Entry.php index 8f800e24ad..ba406bc177 100644 --- a/src/Entries/Entry.php +++ b/src/Entries/Entry.php @@ -390,6 +390,7 @@ public function save() if ($this->isDirty('slug')) { optional(Collection::findByMount($this))->updateEntryUris(); + $this->updateChildPageUris(); } foreach ($afterSaveCallbacks as $callback) { @@ -419,6 +420,28 @@ public function save() return true; } + private function updateChildPageUris() + { + $collection = $this->collection(); + + // If it's orderable (single depth structure), there are no children to update. + // If the collection has no route, there are no uris to update. + // If there's no page, there are no children to update. + if ( + $collection->orderable() + || ! $this->route() + || ! ($page = $this->page()) + ) { + return; + } + + if (empty($ids = $page->flattenedPages()->pluck('id'))) { + return; + } + + $collection->updateEntryUris($ids); + } + public function taxonomize() { Facades\Entry::taxonomize($this);