community-skeleton
community-skeleton copied to clipboard
UVDesk - unable to view/assign some tickets
Bug report
I am unable to assign or view some tickets. Switching from prod to dev mode shows the error "Impossible to access as attribute("createdAt") on a null variable. See image below:
Check on the database shows the tickets are generated (via RefereshMailbox Command) correctly. No errors on ticket generation. Please help.
UVDesk Version v1.1.3; Core Version v1.1.4
Found my problem.
Tickets were being generated successfully but initial threads were not generated in the database.
Current solution has been to identify the tickets and manually create threads for them in the database table.
I also have this issue, is there any permanent fix for this?
Not yet. If occurs because in the Mailbox Service does not have the exception to handle a situation where the ticket header is generated but the thread is not. I have created a program outside of UVDesk to handle this but it is not yet perfect. It can fetch the emails but not the images in the email, and no attachments yet. It also requires configuration and a cron job. I can share that if you want.
Thanks, but I looked more into it and I think I was able to fix it you can test it out on your own if you want on the file /vendor/uvdesk/core-framework/Services/TicketService.php 287 function CreateThread
this line is the problem $collaboratorEmails = array_merge(!empty($threadData['cccol']) ? $threadData['cccol'] : [], !empty($threadData['cc']) ? $threadData['cc'] : []);
I did it like this because of testing but if you replace that with this $collaboratorEmails = [];
//check if $threadData['cc'] is not empty then merge it with $collaboratorEmails
if (!empty($threadData['cc'])) {
//check if $threadData['cc'] is an array if not make it an array
if (!is_array($threadData['cc'])) {
$threadData['cc'] = [$threadData['cc']];
}
$collaboratorEmails = array_merge($collaboratorEmails, $threadData['cc']);
}
//check if $threadData['cccol'] is not empty
if (!empty($threadData['cccol'])) {
//check if $threadData['cccol'] is an array if not make it an array
if (!is_array($threadData['cccol'])) {
$threadData['cccol'] = [$threadData['cccol']];
}
$collaboratorEmails = array_merge($collaboratorEmails, $threadData['cccol']);
}
It should work
This is great, and thank you. I will definitely try it. My initial approach was to try and modify the mailbox service i.e. /vendor/uvdesk/mailbox-component/Services/MailboxService.php 453
I thought of capturing the exception at this point but all I could come up with was a message to show that the "bug" was occurring here. Ichanged it from:
if (!empty($thread)) {
// Thread with the same message id exists skip process.
return [
'message' => "Thread with the same message id exists I.",
'content' => [
'from' => !empty($mailData['from']) ? $mailData['from'] : null,
'thread' => $thread->getId(),
'ticket' => $ticket->getId(),
],
];
}
to
if (!empty($thread)) {
// Thread with the same message id exists skip process.
return [
'message' => "Thread with the same message id exists I.",
'content' => [
'from' => !empty($mailData['from']) ? $mailData['from'] : null,
'thread' => $thread->getId(),
'ticket' => $ticket->getId(),
],
];
} else {
// if ticket is not empty but thread is empty
$mailData['threadType'] = 'create';
$mailData['referenceIds'] = $mailData['messageId'];
$thread->getCreatedBy() == 'customer';
return [
'message' => "I fall here.",
'content' => [
'from' => !empty($mailData['from']) ? $mailData['from'] : null,
'thread' => !empty($thread) ? $thread->getId() : null,
'ticket' => !empty($ticket) ? $ticket->getId() : null,
],
];
}
Will test and give you feedback in 2 days.
5 day feedback: Issues has disappeared so far. No childless tickets. Will give further feedback on/by 22nd June 2024 after a larger test dataset.
25th June 2024, issue has completely disappeared so far.