diff --git a/src/Stache/Stores/CollectionEntriesStore.php b/src/Stache/Stores/CollectionEntriesStore.php index a56433f377f..6c139043d34 100644 --- a/src/Stache/Stores/CollectionEntriesStore.php +++ b/src/Stache/Stores/CollectionEntriesStore.php @@ -160,13 +160,13 @@ protected function storeIndexes() { $indexes = collect([ 'slug', - 'uri', 'collectionHandle', 'published', 'title', 'site' => Indexes\Site::class, 'origin' => Indexes\Origin::class, 'parent' => Indexes\Parents::class, + 'uri', ]); if (! $collection = Collection::findByHandle($this->childKey())) { diff --git a/tests/Stache/OrderableEntryUriTest.php b/tests/Stache/OrderableEntryUriTest.php new file mode 100644 index 00000000000..46115151b0d --- /dev/null +++ b/tests/Stache/OrderableEntryUriTest.php @@ -0,0 +1,50 @@ +routes('/vehicles/{slug}') + ->structureContents(['max_depth' => 1]); + $collection->save(); + } + + private function simulateNewRequest(): void + { + Blink::flush(); + Stache::stores()->each->resetMemoizedState(); + app('stache.indexes')->each->resetMemoizedState(); + } + + #[Test] + public function entries_have_uris_and_orders_after_being_saved() + { + Entry::make()->collection('vehicles')->slug('car')->data(['title' => 'Car'])->save(); + + $this->simulateNewRequest(); + + Entry::make()->collection('vehicles')->slug('bus')->data(['title' => 'Bus'])->save(); + + $this->simulateNewRequest(); + + $this->assertNotNull($car = Entry::findByUri('/vehicles/car')); + $this->assertNotNull($bus = Entry::findByUri('/vehicles/bus')); + $this->assertEquals(1, $car->order()); + $this->assertEquals(2, $bus->order()); + } +}