From 228eeb8a3b9638fbdf3fa57e99249a5c8e6465a8 Mon Sep 17 00:00:00 2001 From: Laurens Kuiper Date: Wed, 23 Sep 2026 13:35:43 +0200 Subject: [PATCH 1/2] fix: give unsaved entries their own blueprint cache key --- src/Entries/Entry.php | 2 +- tests/Data/Entries/EntryTest.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/Entries/Entry.php b/src/Entries/Entry.php index b1113005624..7ff4c5109b0 100644 --- a/src/Entries/Entry.php +++ b/src/Entries/Entry.php @@ -185,7 +185,7 @@ public function collection($collection = null) public function blueprint($blueprint = null) { - $key = "entry-{$this->id()}-blueprint"; + $key = 'entry-'.($this->id() ?? 'obj-'.spl_object_id($this)).'-blueprint'; return $this ->fluentlyGetOrSet('blueprint') diff --git a/tests/Data/Entries/EntryTest.php b/tests/Data/Entries/EntryTest.php index a87b106f23e..2f794afc57d 100644 --- a/tests/Data/Entries/EntryTest.php +++ b/tests/Data/Entries/EntryTest.php @@ -1358,6 +1358,25 @@ public function it_gets_the_default_collection_blueprint_when_undefined() $this->assertNotSame($first, $second); } + #[Test] + public function unsaved_entries_in_different_collections_do_not_share_a_blueprint() + { + BlueprintRepository::shouldReceive('in')->with('collections/blog')->andReturn(collect([ + 'post' => $post = (new Blueprint)->setHandle('post'), + ])); + BlueprintRepository::shouldReceive('in')->with('collections/products')->andReturn(collect([ + 'product' => $product = (new Blueprint)->setHandle('product'), + ])); + $blog = tap(Collection::make('blog'))->save(); + $products = tap(Collection::make('products'))->save(); + + $blogEntry = (new Entry)->collection($blog); + $productEntry = (new Entry)->collection($products); + + $this->assertSame($post, $blogEntry->blueprint()); + $this->assertSame($product, $productEntry->blueprint()); + } + #[Test] public function the_blueprint_is_blinked_when_getting_and_flushed_when_setting() { From 376d8d43edfa052a2f2b70747abced6485d91119 Mon Sep 17 00:00:00 2001 From: Laurens Kuiper Date: Wed, 23 Sep 2026 13:36:07 +0200 Subject: [PATCH 2/2] test: give the pages collection its own blueprint fixture --- tests/Data/Entries/EntryTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Data/Entries/EntryTest.php b/tests/Data/Entries/EntryTest.php index 2f794afc57d..1b37cb24581 100644 --- a/tests/Data/Entries/EntryTest.php +++ b/tests/Data/Entries/EntryTest.php @@ -2173,6 +2173,7 @@ public function it_respects_custom_blueprint_template_path_per_collection() $blueprint = tap(Blueprint::make('standard_article')->setNamespace('collections.articles'))->save(); $articleEntry = Entry::make('test')->collection($articles)->blueprint($blueprint->handle()); + tap(Blueprint::make('standard_article')->setNamespace('collections.pages'))->save(); $pageEntry = Entry::make('test')->collection($pages)->blueprint($blueprint->handle()); // mapped collection uses the mapped prefix instead of the collection handle