Http error 500 on save setting inbound email account

Hello, I ugraded from 7.10.29 to 7.13.0 via 7.12.8 intermediate upgrade.

Now when I manage inbound email settings, with gmail account, if I check connection everything is good, I can browse folders etc.

When I try to do “save settings”, I obtain an HTTP ERROR 500.
Apache log shows the following:

Mon Jan 02 12:49:04.889497 2023] [proxy_fcgi:error] [pid 337591] [client 10.20.66.100:63216] AH01071: Got error 'p on line 184PHP message: PHP Warning: Undefined array key “link” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/cache/smarty/templates_c/%%14^148^14804A90%%DashletGenericDisplay.tpl.php on line 184PHP message: PHP Warning: Undefined array key “customCode” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/cache/smarty/templates_c/%%14^148^14804A90%%DashletGenericDisplay.tpl.php on line 184PHP message: PHP Warning: Undefined array key “tabindex” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/include/Smarty/plugins/function.sugar_field.php on line 104PHP message: PHP Warning: Undefined array key “link” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/cache/smarty/templates_c/%%14^148^14804A90%%DashletGenericDisplay.tpl.php on line 184PHP message: PHP Warning: Undefined array key “bold” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/cache/smarty/templates_c/%%14^148^14804A90%%DashletGenericDisplay.tpl.php on line 184PHP message: PHP Warning: Undefined array key “bold” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/cache/smarty/templates_c/%%14^148^14804A90%%DashletGenericDisplay.tpl.php on line 184PHP message: PHP Warning: Undefined array key “link” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/cache/smarty/templates_c/%%14^148^14804A90%%DashletGenericDisplay.tpl.php on line 184PHP message: PHP Warning: Undefined array key “customCode” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/cache/smarty/templates_c/%%14^148^14804A90%%DashletGenericDisplay.tpl.php on line 184PHP message: PHP Warning: Undefined array key “tabindex” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/include/Smarty/plugins/function.sugar_field.php on line 104PHP message: PHP Warning: Undefined array key “link” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/cache/smarty/templates_c/%%14^148^14804A90%%DashletGenericDisplay.tpl.php on line 184PHP message: PHP Warning: Undefined array key “bold” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/cache/smarty/templates_c/%%14^148^14804A90%%DashletGenericDisplay.tpl.php on line 184PHP message: PHP Warning: Undefined array key “bold” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/cache/smarty/templates_c/%%14^148^14804A90%%DashletGenericDisplay.tpl.php on line 184PHP message: PHP Warning: Undefined array key “link” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/cache/smarty/templates_c/%%14^148^14804A90%%DashletGenericDisplay.tpl.php on line 184PHP message: PHP Warning: Undefined array key “customCode” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/cache/smarty/templates_c/%%14^148^14804A90%%DashletGenericDisplay.tpl.php on line 184PHP message: PHP Warning: Undefined array key “tabindex” in /var/www/suitecrm.mydomain.com/SuiteCRM_713/include/Smarty/plugins/function.sugar_field.php on line 104PHP message:

and similar.
So I think it is an internal error occurred during the update isn’t it?

Have you tried a Quick Repair and Rebuild?

Check that you’re still within the bounds of the Compatibility Matrix.

You can also clear the directory “cache\smarty”, those files will get rebuilt.

Thank you for the quick response.
Sure, quick and rebuild has no complains.
I am within the compatibility matrix, and I did the update in 2 steps exactly to stay within the compatibility matrix during the updates.
I cleared the directory cache/smarty and the result is the same

I am now with php8.0 and apache fpm module (due to multiple php version on the same server). I think the problem is within
Undefined array key “XXX” in .php scripts, even if they are only warnings.

Nothing. I tried to reinstall starting from 7.12.8, but result is the same. At his point, I think this is a bug, and very severe due to the fact that an HTTP 500 error is returned.

I think i will open a bug on GitHub, if no other comments are helping trying me to solve.

You should not be seeing warning in your logs
Have you setup php error_reporting properly

Here is how it should be

I am not convinced (yet) that this is a SuiteCRM bug for Github.

You could have permissions problems, you could have PHP settings problems, etc.

Please look in these two logs (not in the Apache log) for any clues. Focus on two things:

  1. Messages when the screen is built and displayed
  2. Messages when you click to save

EDIT: just to be clear: I don’t believe that the errors you’re currently looking at can cause a fatal and a 500. They’re just smarty errors in tpls, the most that could happen would be a quirk rendering some screen. The logs of people who have no FATALs are filled with this kind of error. You might even compare you own logs before this issue, if you still have them, and find the same errors there.

You are right, I activated the logs as requested, and errors are different. In particular it is relevant the last fatal error:

[03-Jan-2023 13:37:54 Europe/Berlin] PHP Fatal error: Uncaught TypeError: trim(): Argument #1 ($string) must be of type string, array given in /var/www/suitecrm.mydomain.com/SuiteCRM_713/modules/InboundEmail/Save.php:90

Stack trace:

#0 /var/www/suitecrm.mydomain.com/SuiteCRM_713/modules/InboundEmail/Save.php(90): trim()

#1 /var/www/suitecrm.mydomain.com/SuiteCRM_713/include/MVC/View/SugarView.php(824): include_once(’…’)

#2 /var/www/suitecrm.mydomain.com/SuiteCRM_713/include/MVC/View/views/view.classic.php(72): SugarView->includeClassicFile()

#3 /var/www/suitecrm.mydomain.com/SuiteCRM_713/include/MVC/View/SugarView.php(210): ViewClassic->display()

#4 /var/www/suitecrm.mydomain.com/SuiteCRM_713/include/MVC/Controller/SugarController.php(432): SugarView->process()

#5 /var/www/suitecrm.mydomain.com/SuiteCRM_713/include/MVC/Controller/SugarController.php(363): SugarController->processView()

#6 /var/www/suitecrm.mydomain.com/SuiteCRM_713/include/MVC/SugarApplication.php(101): SugarController->execute()

#7 /var/www/suitecrm.mydomain.com/SuiteCRM_713/index.php(52): SugarApplication->execute()

#8 {main}

thrown in /var/www/suitecrm.mydomain.com/SuiteCRM_713/modules/InboundEmail/Save.php on line 90

That’s great, a FATAL with a stack trace :heart_eyes: I wish everybody who has an error here in the forums was able to bring me one of these!

In your file modules/InboundEmail/Save.php, what do you see in line 90? It should have a trim function call, but I can’t match that to line 90 on the core code:
SuiteCRM/Save.php at master · salesagility/SuiteCRM · GitHub

For that same web request (save), in your browsers web developer tools, on the network tab, can you please get the contents of the POST variables (the $_REQUEST). We need to figure out which of those fields is (unexpectedly) containing an array.

Hello, thanks.
Line 90 is:

$focus->$field = trim($_REQUEST[$field]);

do you prefer me to send the whole file?

In the meanwhile, clemente raposo from github was able to reproduce the problem, which don’t happen if 7.f php is used.

Here the POST (if I understood well):

curl ‘http://BLABLABLA/index.php’ \

-X ‘POST’ \

-H ‘Content-Type: application/x-www-form-urlencoded’ \

-H ‘Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8’ \

-H ‘Accept-Encoding: gzip, deflate’ \

-H ‘Accept-Language: it-IT,it;q=0.9’ \

-H ‘Host: BLABLA’ \

-H ‘Origin: http://BLABLA’ \

-H ‘User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.2 Safari/605.1.15’ \

-H ‘Connection: keep-alive’ \

-H ‘Upgrade-Insecure-Requests: 1’ \

-H ‘Referer: http://BLABLA/index.php’ \

-H ‘Content-Length: 1353’
‘Cookie: ck_login_id_20=1; ck_login_language_20=en_us; PHPSESSID=vekq6ugknqlfqnqum7giih5ep7; _fbp=fb.1.1662104229251.932478403; _ga=GA1.1.223195432.1662104229; _ga_GS6ELN1HWH=GS1.1.1672757933.27.1.1672757936.0.0.0; EmailTreeLayout=Home%3A%3AXXXXXXXXXX=false&Home%3A%3AYYYYYYYYYY%3A%3AINBOX=false&e4357d6f-2e8b-da45-948c-60076086727c=false&451e8364-7426-a554-5b63-600760a3a4ab=false&73749af5-4b84-258d-9a72-600760b58b00=false&a1cb0f5d-80c5-dddf-da63-600760ce0d5e=false; EmailGridWidths=0=10&1=10&2=150&3=250&4=175&5=125; Contacts_divs=Contacts_opportunities_v%3Dtrue%23undefined%3D%23Contacts_activities_v%3Dtrue%23Contacts_history_v%3Dtrue%23Contacts_documents_v%3Dtrue%23Contacts_leads_v%3Dtrue%23; Opportunities_sp_tab=All; Contacts_sp_tab=All; Accounts_sp_tab=All’
–data ‘module=InboundEmail&record=e4357d6f-2e8b-da45-948c-60076086727c&isDuplicate=false&action=Save&return_module=InboundEmail&return_action=DetailView&return_id=e4357d6f-2e8b-da45-948c-60076086727c&module_tab=&contact_role=&relate_to=InboundEmail&relate_id=e4357d6f-2e8b-da45-948c-60076086727c&offset=3&searchField=&origin_id=&type=personal&name=XXXXXXXXXXXXXX&status=Active&owner_name=YYYYYYYYYY&created_by=59cba452-84e3-e974-cc30-5febbe208a92&auth_type=basic&external_oauth_connection_name=&external_oauth_connection_id=&server_url=imap.gmail.com&email_user=XXXXXXXXXXX&protocol=imap&email_password=&port=993&mailbox=INBOX&is_ssl=0&trashFolder=Trash&connection_string=&sentFolder=%5BGmail%5D%2FPosta+inviata&outbound_email_name=nome &outbound_email_id=1fd007b4-43a5-fc66-b3cc-600b097c6cf9&account_signature_id=&allow_outbound_group_usage=0&from_name=XXXXXXXXX&reply_to_name=&from_addr=ZZZZZZZZZZZ&reply_to_addr=ZZZZZZZZZZZZZ&filter_domain=&autoreply_email_template_name=&template_id=&email_num_autoreplies_24_hours=10&is_auto_import=0&move_messages_to_trash_after_import=0&is_create_case=0&create_case_email_template_name=&create_case_template_id=&distribution_options%5B0%5D=all&distribution_options%5B1%5D=&distribution_options%5B2%5D=&distribution_user_name=&distribution_user_id=’

If SalesAgility can reproduce it, they can go through this with a debugger. Since that command runs inside a loop cycling through all the fields, it would be important to know which field is causing the problem (there are many!). Hence the debugger is the helpful tool here. I am currently recovering from some hardware problems, my development setup is not functional at the moment.

I got exactly the same error code after upgrading from 7.12.8 to 7.13. Ubuntu 20.04, XAMPP for Linux 8.0.25 (Apache/2.4.54 (Unix) OpenSSL/1.1.1s PHP/8.0.25, MariaDB/10.4.27). Any idea?

Just switch to php7.4 instead of 8.0 and you have solved (while you wait for the proper patch)

I just found such a suggestion - issue #9878 on github. Thanks for your reply.