Skip to content

Commit 3304a9f

Browse files
[5.x] Account for custom fields when checking if entry URIs should be updated (#13859)
1 parent 81148db commit 3304a9f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/Entries/Entry.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public function save()
416416

417417
$this->taxonomize();
418418

419-
if ($this->isDirty('slug')) {
419+
if ($this->shouldUpdateUris()) {
420420
optional(Collection::findByMount($this))->updateEntryUris();
421421
$this->updateChildPageUris();
422422
}
@@ -448,6 +448,21 @@ public function save()
448448
return true;
449449
}
450450

451+
private function shouldUpdateUris(): bool
452+
{
453+
if (! $this->route()) {
454+
return false;
455+
}
456+
457+
$antlersRoute = preg_replace_callback('/{\s*([a-zA-Z0-9_\-]+)\s*}/', function ($match) {
458+
return "{{ {$match[1]} }}";
459+
}, $this->route());
460+
461+
return collect(Antlers::identifiers($antlersRoute))
462+
->filter(fn (string $identifier) => $this->isDirty($identifier))
463+
->isNotEmpty();
464+
}
465+
451466
private function updateChildPageUris()
452467
{
453468
$collection = $this->collection();

0 commit comments

Comments
 (0)