statamic / eloquent-driver

Provides support for storing your Statamic data in a database, rather than flat files.
https://statamic.dev/tips/storing-content-in-a-database
MIT License
104 stars 73 forks source link

[4.x] Cannot set date on non-dated collection entry error when running `search:update` #148

Closed robdekort closed 1 year ago

robdekort commented 1 year ago

I just noticed that when you running php please search:update on a v4 site (only when) using Eloquent you get this error:

Screenshot 2023-04-24 at 20 48 39
[2023-04-24 20:49:50] local.ERROR: Cannot set date on non-dated collection entry. {"exception":"[object] (LogicException(code: 0): Cannot set date on non-dated collection entry. at /Users/robdekort/Sites/lutjegeluk/vendor/statamic/cms/src/Entries/Entry.php:461)
[stacktrace]
#0 /Users/robdekort/Sites/lutjegeluk/vendor/statamic/cms/src/Support/FluentGetterSetter.php(130): Statamic\\Entries\\Entry->Statamic\\Entries\\{closure}(Object(Illuminate\\Support\\Carbon))
#1 /Users/robdekort/Sites/lutjegeluk/vendor/statamic/cms/src/Support/FluentGetterSetter.php(97): Statamic\\Support\\FluentGetterSetter->runSetterLogic(Object(Illuminate\\Support\\Carbon))
#2 /Users/robdekort/Sites/lutjegeluk/vendor/statamic/cms/src/Entries/Entry.php(482): Statamic\\Support\\FluentGetterSetter->args(Array)
#3 /Users/robdekort/Sites/lutjegeluk/vendor/statamic/eloquent-driver/src/Entries/Entry.php(27): Statamic\\Entries\\Entry->date(Object(Illuminate\\Support\\Carbon))
#4 /Users/robdekort/Sites/lutjegeluk/vendor/statamic/eloquent-driver/src/Entries/EntryQueryBuilder.php(24): Statamic\\Eloquent\\Entries\\Entry::fromModel(Object(Statamic\\Eloquent\\Entries\\UuidEntryModel))
#5 [internal function]: Statamic\\Eloquent\\Entries\\EntryQueryBuilder->Statamic\\Eloquent\\Entries\\{closure}(Object(Statamic\\Eloquent\\Entries\\UuidEntryModel), 0)
#6 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(558): array_map(Object(Closure), Array, Array)
#7 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(770): Illuminate\\Support\\Arr::map(Array, Object(Closure))
#8 /Users/robdekort/Sites/lutjegeluk/vendor/statamic/eloquent-driver/src/Entries/EntryQueryBuilder.php(23): Illuminate\\Support\\Collection->map(Object(Closure))
#9 /Users/robdekort/Sites/lutjegeluk/vendor/statamic/cms/src/Query/EloquentQueryBuilder.php(59): Statamic\\Eloquent\\Entries\\EntryQueryBuilder->transform(Object(Illuminate\\Database\\Eloquent\\Collection), Array)
#10 /Users/robdekort/Sites/lutjegeluk/vendor/statamic/eloquent-driver/src/Entries/EntryQueryBuilder.php(67): Statamic\\Query\\EloquentQueryBuilder->get(Array)
#11 /Users/robdekort/Sites/lutjegeluk/vendor/statamic/cms/src/Search/Searchables/Entries.php(33): Statamic\\Eloquent\\Entries\\EntryQueryBuilder->get()
#12 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Collections/HigherOrderCollectionProxy.php(60): Statamic\\Search\\Searchables\\Entries->provide()
#13 [internal function]: Illuminate\\Support\\HigherOrderCollectionProxy->Illuminate\\Support\\{closure}(Object(Statamic\\Search\\Searchables\\Entries), 'collection')
#14 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Collections/Arr.php(558): array_map(Object(Closure), Array, Array)
#15 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(770): Illuminate\\Support\\Arr::map(Array, Object(Closure))
#16 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(370): Illuminate\\Support\\Collection->map(Object(Closure))
#17 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Collections/HigherOrderCollectionProxy.php(59): Illuminate\\Support\\Collection->flatMap(Object(Closure))
#18 /Users/robdekort/Sites/lutjegeluk/vendor/statamic/cms/src/Search/Searchables.php(43): Illuminate\\Support\\HigherOrderCollectionProxy->__call('provide', Array)
#19 /Users/robdekort/Sites/lutjegeluk/vendor/statamic/cms/src/Search/Index.php(60): Statamic\\Search\\Searchables->all()
#20 /Users/robdekort/Sites/lutjegeluk/vendor/statamic/cms/src/Search/Commands/Update.php(25): Statamic\\Search\\Index->update()
#21 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Statamic\\Search\\Commands\\Update->handle()
#22 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#23 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure(Object(Closure))
#24 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(35): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#25 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Container/Container.php(662): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#26 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Console/Command.php(194): Illuminate\\Container\\Container->call(Array)
#27 /Users/robdekort/Sites/lutjegeluk/vendor/symfony/console/Command/Command.php(312): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#28 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Console/Command.php(163): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#29 /Users/robdekort/Sites/lutjegeluk/vendor/symfony/console/Application.php(1022): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#30 /Users/robdekort/Sites/lutjegeluk/vendor/symfony/console/Application.php(314): Symfony\\Component\\Console\\Application->doRunCommand(Object(Statamic\\Search\\Commands\\Update), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#31 /Users/robdekort/Sites/lutjegeluk/vendor/symfony/console/Application.php(168): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#32 /Users/robdekort/Sites/lutjegeluk/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(200): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#33 /Users/robdekort/Sites/lutjegeluk/please(35): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#34 {main}
"} 
ryanmitchell commented 1 year ago

Does this help at all? Sorry to keep relying on you to test v4 fixes, I really need to get a testing repo running.

robdekort commented 1 year ago

No worries Ryan! We're all happily volunteering :-)

Works like a charm.

robdekort commented 1 year ago

Fixed in #142.