Stillat / relationships

Provides automated bi-directional @statamic entry relationships
MIT License
16 stars 1 forks source link

__clone method called on non-object #28

Closed markusreis-yd closed 7 months ago

markusreis-yd commented 8 months ago

Hey there,

I am not quite sure if I am right, but shouldn't this line check, if an ID exists / the model property is_null? You already do the isUpdating check in the respective SavingListeners (eg. EntrySavingListener) but then you try to clone it anyways in the DB-Check Method.

When I create a new entry within my collection, I get the exception [2023-11-20 09:23:33] local.ERROR: __clone method called on non-object {"userId":1,"exception":"[object] (Error(code: 0): __clone method called on non-object at /var/www/html/vendor/stillat/relationships/src/Listeners/BaseListener.php:15)

When I update an existing entry, everything is fine.

JohnathonKoster commented 8 months ago

I'll try to take a look sometime this week before some holidays here

If you are able to submit a PR in the meantime that I can review, I would really appreciate that. Thank you!

markusreis-yd commented 8 months ago

Hey Jonathon, created a pull request. I didn't deeply check but it fixes the error on my end and the inverse relationship still gets set

cheers

JohnathonKoster commented 8 months ago

Thank you! I will review this evening my time!