Doctrine 1.2: events with out-of-date invokers cause problem with versionable behaviour
I have a feeling there might be something I am missing here, but here I go anyway.
Consider this: I have a 'Booking' class that has a user_id field and the Versionable behaviour and I run the following code:
$booking = new Booking();
$booking->user_id = 1;
$booking->isValid();
$booking->user_id = 2;
$booking->save();
This results in the correct record being inserted into the 'booking' table. BUT the record that is inserted into 'booking_version' table is out of date! The user_id is set to 1 because the data is pulled off the event invoker that was created during the first isValid() call开发者_Python百科. Furthermore, the id field is set to 0 for the same reason (which means the version record cannot be linked back to the booking)
I can get around this problem by calling $booking->clearInvokedSaveHooks() before the save(), but I dont really want to do this because I dont want to run all my save hooks again on saving.
Is there a better way to get around this?
There is nothing to workaround here. Versionable
behaviour is designed to store previous values of the record.
If you want to store every single temporary state of the object - you'll have to save
it each time.
精彩评论