AndyB
Well-known member
How can I prevent server errors like this:
I have the following code:
The server error only occurs once in a while. I understand this is a "race condition" and it's okay to ignore the server error message.
My question, is there any way to prevent this race condition or suppress the server error log?
Thank you.
XF\Db\DuplicateKeyException: MySQL query error [1062]: Duplicate entry
I have the following code:
PHP:
if (empty($forumListCount))
{
$forumListCount = \XF::em()->create('Andy\ForumListCount:ForumListCount');
$forumListCount->count_date = $today;
$forumListCount->count_guest = 0;
$forumListCount->count_member = 0;
$forumListCount->count_robot = 0;
$forumListCount->save();
}
The server error only occurs once in a while. I understand this is a "race condition" and it's okay to ignore the server error message.
My question, is there any way to prevent this race condition or suppress the server error log?
Thank you.