owen-it / laravel-auditing

Record the change log from models in Laravel
https://laravel-auditing.com
MIT License
3.01k stars 387 forks source link

Serialization of 'PDO' is not allowed - Queued Audits #879

Closed philip1337 closed 9 months ago

philip1337 commented 9 months ago
Q A
Bug? yes
New Feature? yes
Framework Laravel
Framework version 10.10
Package version v13.6.0
PHP version 8.3.0

Actual Behaviour

stacktrace.txt

After upgrading to v13.6.0 with the new queued audits feature, ends up in serialization issues.

Expected Behaviour

Should save the model I guess

Steps to Reproduce

Upgrade to the new laravel-auditing version.

Possible Solutions

Downgrade a version below.

angeljqv commented 9 months ago

846

Orrison commented 9 months ago

Just to confirm, based on your stack trace you have audit.queue.connection set to sync right? If so, any more details on the issue you could provide? What does your Model look like that is through this serialization issue?

philip1337 commented 9 months ago

Hello,

it's from an upgrade. I didn't touch the setting.

So it's the default one: https://github.com/owen-it/laravel-auditing/blob/v13.6.0/config/audit.php#L168-L172

From the stack trace we can see it's using the SyncQueue:

  {
      "file": "vendor/laravel/framework/src/Illuminate/Queue/SyncQueue.php",
      "line": 38,
      "function": "createPayload",
      "class": "Illuminate\\Queue\\Queue",
      "type": "->"
  },

I can confirm that accesing the setting is resulting in 'sync'. 'config("audit.queue.connection")'

Model

My model is a bit more complex than the normal ones. I think it's related to an attribute from the model that can't be serialized.

I'll try to provide more informations asap regarding the model.

MortenDHansen commented 9 months ago

Yeah, it looks like it wont serialize. The problem seems to be from the model like you suspect. If you can get us some details on what cant be serialized, we could try and test and find a way to deal with it. I haven't found a case to recreate the issue with.

@Orrison - can you help?

In the meantime, you may of course simply revert back to the previous version in composer.json

Orrison commented 9 months ago

@MortenDHansen sure thing.

@philip1337 that makes sense. From the look of the stacktrace it seems you have an attribute that is possibly something like a QueryBuilder? More details on the attribute would help track down the issue and what could be done to fix it.

erikn69 commented 9 months ago

Try disable it with #881

philip1337 commented 9 months ago

Try disable it with #881

It is already disabled but since it's getting dispatched trough the SyncQueue it's still getting serialized. I started debugging it and I'll post an update asap on how it happens. I can reproduce it I just didn't find the time to look into it.

MortenDHansen commented 9 months ago

The opt-in version of v13.6.0 has been released. I hope that solves it :)

philip1337 commented 9 months ago

It solved it.

As mentioned before my assumption turned out correct, there was an attribute that one of the other developers set that couldn't be serialized.

Thanks for the help, I really like this library!

Kind regards Philip