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
108 stars 78 forks source link

Reorder issue. #368

Open JesperFiltenborg opened 4 weeks ago

JesperFiltenborg commented 4 weeks ago

Bug description

Hey, I've gotten a site for a customer running Statamic 4 and Statamic eloquent driver. The site has been migrated from a Statamic 3 with Statamic eloquent driver.

The problem i really odd. I've got a collection using reorder with a max depth of 1. When i reorder I can see that my database tree is updated but the order on the entries in the database say the same. If i change the max depth to 0 / blank it works as expected.

I do not know if this is an actual bug or if it's a problem that happened during the migration.

How to reproduce

I cannot reproduce it on a fresh install, but hope to get some help either in this thread or through a discord call.

Logs

No response

Environment

Environment
Application Name: *********
Laravel Version: 10.48.12
PHP Version: 8.2.22
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: *********.ddev.site
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: redis
Database: mysql
Logs: daily
Mail: smtp
Queue: sync
Session: redis

Statamic
Addons: 6
Antlers: runtime
Sites: 2 (Danish, English)
Stache Watcher: Disabled
Static Caching: Disabled
Version: 4.58.2 PRO

Statamic Addons
doublethreedigital/duplicator: 4.0.1
jacksleight/statamic-bard-mutator: 2.3.0
pecotamic/sitemap: 1.4.6
statamic/eloquent-driver: 3.4.1

Statamic Eloquent Driver
Asset Containers: file
Assets: eloquent
Blueprints: file
Collection Trees: file
Collections: eloquent
Entries: eloquent
Forms: eloquent
Global Sets: eloquent
Global Variables: file
Navigation Trees: file
Navigations: eloquent
Revisions: eloquent
Taxonomies: file
Terms: eloquent

Additional details

No response

ryanmitchell commented 4 weeks ago

Is there any reason you can't update the site to v5 and the latest eloquent driver version?

JesperFiltenborg commented 3 weeks ago

@ryanmitchell I've got a version of Statamic 5 running on a development environment, but I experience the same bug with reorder on v5.

ryanmitchell commented 3 weeks ago

You had previously said you dont encounter the error on a fresh install - is this no longer the case?

When i reorder I can see that my database tree is updated but the order on the entries in the database say the same.

can you explain what this means - with some screenshots or examples of the difference in output versus what you were expecting?

JesperFiltenborg commented 3 weeks ago

@ryanmitchell on a fully fresh Statamic install in the newest version i don't encounter this issue. When i debug the code i can see that my database is updated to the correct order in the "trees" table but that the order on the "entries" table is not updated. It looks like Statamic trying to update the order on the Entries through jobs running via horizon. But this should not be the problem due to the reorder not working in sync mode either. Can we perhaps find a time for a discord call, and i can screen share the issue.

ryanmitchell commented 3 weeks ago

Yes the reordering uses a job. Interesting that it works fine on a new install. Feel free to reach out on discord and we can set something up.

ryanmitchell commented 1 week ago

I think https://github.com/statamic/eloquent-driver/pull/377 should solve this. It seems to have not been noticed before as it only happens on queues.