[Vtigercrm-developers] failed crmentity save transactions

Adam Heinz amh at metricwise.net
Thu May 23 21:28:44 UTC 2013


I've seen some other people on the list mention that they have used indexes
to improve their query performance.  We do as well.  We also use a unique
index for quote_no and are in the process of allowing users to manually
specify that value.  If a user attempts to use a quote_no already in use,
the operation needs to fail.

I've started implementing an optimistic commit strategy.  I'm not writing
any additional checks before the commit, so I will be relying on my unique
index to fail the transaction.  I'm using a standard DetailViewAjax
endpoint, so if I can null $focus->id, it will report a failure [1].  I can
check for the failed transaction in saveentity() before the transaction is
completed [2] and unset the id.  Now we just have to deal with the
additional database calls outside of the transaction; relateEntities() and
the aftersave event handlers.

What sort of behavior do people expect here?  I am of the opinion that we
should short circuit past both relateEntities() and the aftersave handlers.
 Maybe call a new aftersave.fail event?

This solution is quite a bit shy of what I'd really like to do; enable
ADOdb exceptions (though I do turn them on for my phpunit tests), but the
codebase is nowhere near ready for that sort of shenanigans.  ;)

[1]
http://trac.vtiger.com/cgi-bin/trac.cgi/browser/vtigercrm/branches/5.4.0/modules/Quotes/DetailViewAjax.php#L33
[2]
http://trac.vtiger.com/cgi-bin/trac.cgi/browser/vtigercrm/branches/5.4.0/data/CRMEntity.php#L93
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20130523/939ac6b8/attachment.html>


More information about the vtigercrm-developers mailing list