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 74 forks source link

Events not dispatched upon save. #118

Closed addgod closed 1 year ago

addgod commented 1 year ago

When saving an entry, then it seems that the EntrySaving event is not dispatched.

From what I can see in the code, the EntryCreated, EntryDeleted and EntrySaved does not seem to be dispatched either.

ryanmitchell commented 1 year ago

They definitely should be firing (and do for me on our usage of this driver).

Eloquent Entry inherits from the file-based Entry which is where all the event firing takes place.

Can you share some code to show what you're doing, or provide a sample repo with the issue so I can look into it further?

addgod commented 1 year ago
protected $listen = [
        EntrySaving::class => [
            EntrySavingListener::class,
        ],
        EntrySaved::class => [
            EventSavedListener::class,
        ],
];

Here the EntrySavedListener is fired, but the EntrySavingListener did not fire.

ryanmitchell commented 1 year ago

I just tested in on one of our sites using the driver and it worked fine for me so it does seem to be something specific to your setup.

If you can provide full code showing what you're doing I'll take a further look.

addgod commented 1 year ago

To share the whole thing I cannot since it is for a customer, and it is a fairly large project.

But I basically just do the above, and then dd in the handle function in the listener to see if it gets to it. Ill add some event debugging and see what happens.

addgod commented 1 year ago

The only thing I can think of that might make a difference, is that this happens in a Statamic addon. And I am using the listen property inside its service provider.

addgod commented 1 year ago

Ahh ffs, I have the problem, i'll close the issue. Someone else fucked up other places in the code.