NOW MANAGED ON CODEBERG
Copying: Fixed issue with non-page links to page permalinks
Dan Brown3cd3e73f607d
diff --git a/app/References/ReferenceChangeContext.php b/app/References/ReferenceChangeContext.phpindex f11619813..27de0e2d2 100644--- a/app/References/ReferenceChangeContext.php+++ b/app/References/ReferenceChangeContext.php@@ -17,17 +17,6 @@ class ReferenceChangeContext$this->changes[] = [$oldEntity, $newEntity];}- /**- * Get all the change pairs.- * Returned array is an array of pairs, where the first item is the old entity- * and the second is the new entity.- * @return array<array{0: Entity, 1: Entity}>- */- public function getChanges(): array- {- return $this->changes;- }-/*** Get all the new entities from the changes.*/diff --git a/app/References/ReferenceUpdater.php b/app/References/ReferenceUpdater.phpindex b811fe868..42de72fde 100644--- a/app/References/ReferenceUpdater.php+++ b/app/References/ReferenceUpdater.php@@ -61,7 +61,7 @@ class ReferenceUpdater$this->updateReferencesWithinEntity($new, $oldToEntity->getUrl(), $newToEntity->getUrl());if ($newToEntity instanceof Page && $oldToEntity instanceof Page) {- $this->updateReferencesWithinPage($newToEntity, $oldToEntity->getPermalink(), $newToEntity->getPermalink());+ $this->updateReferencesWithinEntity($new, $oldToEntity->getPermalink(), $newToEntity->getPermalink());}$reference->to_id = $newToEntity->id;$reference->to_type = $newToEntity->getMorphClass();diff --git a/tests/Entity/CopyTest.php b/tests/Entity/CopyTest.phpindex 43fe12083..d4b6d54cf 100644--- a/tests/Entity/CopyTest.php+++ b/tests/Entity/CopyTest.php@@ -265,6 +265,25 @@ class CopyTest extends TestCase$this->assertStringNotContainsString($page->getUrl() . '"', $newChapter->description_html);}+ public function test_chapter_copy_updates_internal_permalink_references_in_its_description()+ {+ $chapter = $this->entities->chapterHasPages();+ /** @var Page $page */+ $page = $chapter->pages()->first();++ $this->asEditor()->put($chapter->getUrl(), [+ 'name' => 'Internal ref test',+ 'description_html' => '<p>This is a test <a href="' . $page->getPermalink() . '">page link</a></p>',+ ]);+ $chapter->refresh();++ $this->post($chapter->getUrl('/copy'), ['name' => 'My copied chapter']);+ $newChapter = Chapter::query()->where('name', '=', 'My copied chapter')->first();++ $this->assertStringContainsString('/link/', $newChapter->description_html);+ $this->assertStringNotContainsString($page->getPermalink() . '"', $newChapter->description_html);+ }+public function test_page_copy_updates_internal_self_references(){$page = $this->entities->page();