You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every few days or so, our laravel app logs report an error Trying to access array offset on value of type null. From initial research, this error seems to be related to forwarding messages in Freescout without specifying a 'TO' address (i.e., only listing addresses in the CC field).
Steps to reproduce
System Info
Version
App Version
1.8.20
PHP
8.0.21
Enter into an inbox
Open a conversation.
Click 3 elipsis > Forward
Important: Leave "To" field blank
Just enter addresses into the CC field.
Try to send - you will receive a "network connection error" and message won't send.
Check Logs
Open Freescout Instance as admin.
Go to Manage > Logs > App Logs
Open one of the recent laravel logs: e.g., laravel-2022-08-31.log
View Error: Trying to access array offset on value of type null
What is the current bug behavior?
Logs report Trying to access array offset on value of type null. Error is thrown if user attempts to forward message without specifying a TO address and only specifies addresses in CC field.
What is the expected correct behavior?
User should be shown a pop stating they must specify a TO address if they can't forward a message with a blank TO field.
Relevant logs and/or screenshots
Trying to access array offset on value of type null {"userId":29,"email":"[redacted address]","exception":"[object] (ErrorException(code: 0): Trying to access array offset on value of type null at /www/html/app/Http/Controllers/ConversationsController.php:698)
Error User sees when trying to forward email without 'TO' address
The issue seems to be caused by trying to forward a message but not adding anyone to the 'TO' field but having addresses in the 'CC' field. The user receives an error popup that does not indicate how they might fix the issue/send the message. One solution might involve adding a check for an empty to_email[] array before attempting to assign the $to variable, and if it's empty sending a popup to the user to specify a TO address? Another solution might include allowing users to only CC addresses without specifying a TO address.
I don't know PHP very well, but I imagine the solution looking something like:
// To is a single email string.
$to = '';
// List of emails.
$to_list = [];
if ($is_forward) {
if (is_null($request->to_email[0])) {
// send info popup to user letting them know they need to add a TO address
}
else {
$to = $request->to_email[0];
}
} else {
if (!empty($request->to)) {
// When creating a new conversation, to is a list of emails.
if (is_array($request->to)) {
$to = $request->to[0];
} else {
$to = $request->to;
}
} else {
$to = $conversation->customer_email;
}
}
Summary
Every few days or so, our laravel app logs report an error
Trying to access array offset on value of type null
. From initial research, this error seems to be related to forwarding messages in Freescout without specifying a 'TO' address (i.e., only listing addresses in the CC field).Steps to reproduce
Check Logs
laravel-2022-08-31.log
Trying to access array offset on value of type null
What is the current bug behavior?
Logs report
Trying to access array offset on value of type null
. Error is thrown if user attempts to forward message without specifying a TO address and only specifies addresses in CC field.What is the expected correct behavior?
User should be shown a pop stating they must specify a TO address if they can't forward a message with a blank TO field.
Relevant logs and/or screenshots
Error User sees when trying to forward email without 'TO' address
Full Stack Trace
Possible fixes
The error is referencing this line in the source code: /www/html/app/Http/Controllers/ConversationsController.php:698
The issue seems to be caused by trying to forward a message but not adding anyone to the 'TO' field but having addresses in the 'CC' field. The user receives an error popup that does not indicate how they might fix the issue/send the message. One solution might involve adding a check for an empty
to_email[]
array before attempting to assign the$to
variable, and if it's empty sending a popup to the user to specify a TO address? Another solution might include allowing users to only CC addresses without specifying a TO address.I don't know PHP very well, but I imagine the solution looking something like:
Related Issues
This issue might be related to: #554
The text was updated successfully, but these errors were encountered: