Email modules throw 500 error

I am currently experiencing an issue when I go to the Emails menu under any of Marketing, Support, Activities, upon entering any, the page displays only the Emails title and a textless button which opens an empty modal on click.

I am getting a 500 error on the request, e.g.
module=Emails&action=index&parentTab=Activities (500)

I can see on the console an error that displays

SyntaxError: "undefined" is not valid JSON
    at JSON.parse
    at Object
    at ListViewHeader.js

and on the logs on the server I’m getting

FastCGI sent in stderr: "PHP message: PHP Warning:  Undefined array key "moduleList" in /path/to/SuiteCRM/cache/smarty/templates_c/%%F6^F60^F609237E%%_headerModuleList.tpl.php

I’ve searched regarding this topic but was unable to find anything that helped

Hi, welcome to the Community! :tada:

Have a look here, please

In your case, it would be especially helpful to know your SuiteCRM version, and your PHP version. Thanks!

Hi thanks for the note

My current CRM Version is 7.12.2, Sugar Version 6.5.25, PHP 8.1.16
Additionally the suitecrm.log does not throw any new entry when navigating to the module

I already checked permissions related issues but the problem remains

I believe you’re running a PHP version outside the matrix:

I would also advise upgrading to a newer version, at least a newer 7.12, if you don’t want to take the jump to 7.13 (which essentially updates email configuration functionality). Upgrading to v8 is a whole different matter, I’d advise a much more prudent approach there.

Thanks
I’ve updated the version to 7.13.1 and we are using PHP 8.0, but the problems persist, the Emails module remains broken with the same results mentioned on the initial description

Ok.

Normally a 500 error is a FATAL error on the server, which you should find in one of your two logs.

The error you posted earlier is just a warning, and I don’t think it is relevant. Can you find something else there? Pay attention to the timestamps, look for errors coming up exactly when you’re using the broken screens.

Looking at the other log file I find

Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/html/SuiteCRM/cache/smarty/templates_c/%%AF^AF1^AF13FE7B%%ListViewGeneric.tpl.php:45
Stack trace:
#0 /var/www/html/SuiteCRM/vendor/smarty/smarty/libs/Smarty.class.php(1269): include()
#1 /var/www/html/SuiteCRM/include/Sugar_Smarty.php(151): Smarty->fetch()
#2 /var/www/html/SuiteCRM/include/ListView/ListViewSmarty.php(331): Sugar_Smarty->fetch()
#3 /var/www/html/SuiteCRM/include/MVC/View/views/view.list.php(285): ListViewSmarty->display()
#4 /var/www/html/SuiteCRM/include/MVC/View/views/view.list.php(391): ViewList->listViewProcess()
#5 /var/www/html/SuiteCRM/include/MVC/View/SugarView.php(210): ViewList->display()
#6 /var/www/html/SuiteCRM/include/MVC/Controller/SugarController.php(432): SugarView->process()
#7 /var/www/html/SuiteCRM/include/MVC/Controller/SugarController.php(363): SugarController->processView()
#8 /var/www/html/SuiteCRM/include/MVC/SugarApplication.php(101): SugarController->execute()
#9 /var/www/html/SuiteCRM/index.php(52): SugarApplication->execute()
#10 {main}
  thrown in /var/www/html/SuiteCRM/cache/smarty/templates_c/%%AF^AF1^AF13FE7B%%ListViewGeneric.tpl.php on line 45

The Line on that file is as follows

<?php if (count ( $this->_tpl_vars['data'] ) == 0): ?>

Ok, that’s more like it :slight_smile:

You can start by deleting the file that generates the error,

/var/www/html/SuiteCRM/cache/smarty/templates_c/%%AF^AF1^AF13FE7B%%ListViewGeneric.tpl

It’s a cache file, it will get automatically re-created. My idea for this test is simple to see if it is a random, transient error that will go away magically, or if the same error will come up in the recreated file.

The next test I suggest is to try PHP 7.4. If it fixes it, at least you have a clue about what sorts of things to look for (PHP 7.4 —> 8.0 incompatibilities).

I’ve done the switch to PHP 7.4 and removed the cache files, but still no luck the when entering the Module the cache files are recreated as an exact copy of what it was and still throws the same fatal error on the log file

Replace this

<?php if (count ( $this->_tpl_vars['data'] ) == 0): ?>

with this

<?php if ( is_countable($this->_tpl_vars['data']) && count ( $this->_tpl_vars['data'] ) == 0): ?>

That would have to be done in the original .tpl, not in the cached/compiled version

Could you tell me where to find the original file? I’ve searched for files named ListViewGeneric, but none of them include the string above, I imagine it’s because <?php if (count ( $this->_tpl_vars['data'] ) == 0): ?> is not actually what I need to search for on the original file

I searched, but also couldn’t find it.

I went looking for a matching ListViewGeneric compiled tpl on my system, but curiously, it’s not there.

Can you please post the full contents of your file? This will give me more clues to search.

By looking at the cache file’s first line I can see where it compiled from. it was in the themes/SuiteP/include/ListView/ListViewGeneric.tpl, line 73

I replaced

{if count($data) == 0}

To

{if is_countable($data) && count($data) == 0}

And now the Email module is working, thanks

1 Like

Good!

Can you please post an issue about this on Github, so it gets fixed for everyone? Thanks