Facing Problem in Email DetailView

Hi,
I am facing the issue in Emails ‘Detail View’. Please check the below attached file.

Version : suitecrm 7.10.7

Thanks

Hello,

I am having the same problem.

Running :
SuiteCRM v.7.10.7
XAMPP v.3.2.2
Windows Server 2012 R2 Standard
Fresh install

Emails list view is working fine and they import correctly
The error occurs when clicking on an email subject to read the content from all modules (emails, history in contact, etc…)

Attached the corresponding SuiteCRM log and screen
No Php errors (logging set to all - working fine)

The following PHP errors have already been fixed :

[code]
[02-Jul-2018 19:56:02 Europe/Berlin] PHP Notice: Undefined index: has_attachment in D:\xampp\htdocs\suitecrm_immobilier\modules\Emails\include\ListView\ListViewDataEmails.php on line 579
[02-Jul-2018 19:56:20 Europe/Berlin] PHP Notice: Undefined variable: emailAddress in D:\xampp\htdocs\suitecrm_immobilier\modules\Emails\include\displayEmailAddressOptInField.php on line 80
[\code]

Thank you for your help on this,

Best regards,

Anthony

$emailAddress error can be solved with this:

https://github.com/salesagility/SuiteCRM/pull/6055/files

tell me if it fixes anything.

I had indeed applied this fix to solve the $emailAddress error

However it doesn’t fix anything visible, and in particular it doesn’t help with the code showing in email details

Also the has_attachment error was solved by replacing on line 509


case 'has_attachments':

with


case 'has_attachment':

So that it could process line 579.
Also not helping with the code showing in email details…

@antorogiers please clarify

Does the ‘has_attachments’ fix clear the error message from the logs? I understand it doesn’t solve your issue, but at least I want to know if fixes the message.

Then, can you please check your browser’s developer console for any errors when the page breaks?

Yes it fixed these errors that are not showing in my php_error log anymore

I am still having the following errors in php_error every time my cron task is running :
It does not affect email incoming in suitecrm inbox nor emails import into activities.
I have no idea if it can play something in the email details view.


[03-Jul-2018 18:15:33 UTC] PHP Warning:  Module 'openssl' already loaded in Unknown on line 0
[03-Jul-2018 20:15:36 Europe/Berlin] PHP Notice:  Undefined variable: isGroupFolderExists in D:\xampp\htdocs\suitecrm_immobilier\modules\Schedulers\_AddJobsHere.php on line 641
[03-Jul-2018 20:15:36 Europe/Berlin] PHP Notice:  Undefined property: User::$team_set_id in D:\xampp\htdocs\suitecrm_immobilier\modules\Schedulers\_AddJobsHere.php on line 96
[03-Jul-2018 20:15:39 Europe/Berlin] PHP Notice:  Undefined variable: isGroupFolderExists in D:\xampp\htdocs\suitecrm_immobilier\modules\Schedulers\_AddJobsHere.php on line 237

In the console I get this on the email details page that is showing code :


SyntaxError: unterminated regular expression literal                          index.php:1101:5

When clicking on index.php:1101:5 at the right it shows the code of this page
http://myserver/mysuitecrmfolder/index.php?module=Emails&action=DetailView&record=f2ae765c-3aac-896a-50b5-5b3b1bff3c35
and in particular it goes to the section of the literal expression :


<script language="javascript">
    {literal}
    SUGAR.util.doWhen(function () {
        return $("#contentTable").length == 0;
    }, SUGAR.themes.actionMenu);
    {/literal}
</script>

I think that those {literal} {/literal} tags shouldn’t be there at all. They are used to build the screens but shouldn’t be appearing on the final rendered page.

The tricky part is to find out where they are defined, and why they are getting dumped into the page…

This is surely a bug, I’d like to see if we can reproduce it.

Does the broken screen appear with every single imported email you have, or only with specific emails?

Hi,

The broken screen appears with every single imported email.

However, I have just found out interesting points :

  • If emails are imported into cases it shows the body of the email on the dashboard (screen attached).

  • Body of the emails alsea appears in history overview contacts (screen attached)

Also, when trying to read one of these particular emails directly from inbox, it raises new php errors :


Notice: Undefined property: stdClass::$parts in D:\xampp\htdocs\suitecrm_immobilier\modules\InboundEmail\InboundEmail.php on line 3874
Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\suitecrm_immobilier\modules\InboundEmail\InboundEmail.php on line 4142

Emails that have been imported (marked with a tick) but not linked to any contacts (no matching input in database) do not raise these errors, I only get the broken screen.

So it looks like the program is able to read emails correctly but not to display them properly when requested…

Any thoughts ?

Forgot the screens sorry
Now attached

Not sure if this helps.
I just ran a search in all suitecrm files for ‘{literal}’ producing 3386 hits in 387 files
Then narrowed to ‘DetailView’ producing 428 hits in 89 files
Here is the result narrowed to ‘#contentTable’ producing 5 hits in 5 files


Search "contenttable" (5 hits in 5 files)
  D:\xampp\htdocs\suitecrm_immobilier\cache\smarty\templates_c\%%7C^7C6^7C661FC5%%header.tpl.php (1 hit)
	Line 52:         return $("#contentTable").length == 0;
  D:\xampp\htdocs\suitecrm_immobilier\cache\themes\SuiteP\modules\Accounts\DetailView.tpl (1 hit)
	Line 6:         return $("#contentTable").length == 0;
  D:\xampp\htdocs\suitecrm_immobilier\cache\themes\SuiteP\modules\Contacts\DetailView.tpl (1 hit)
	Line 6:         return $("#contentTable").length == 0;
  D:\xampp\htdocs\suitecrm_immobilier\include\DetailView\header.tpl (1 hit)
	Line 48:     return $("#contentTable").length == 0;
  D:\xampp\htdocs\suitecrm_immobilier\themes\SuiteP\include\DetailView\header.tpl (1 hit)
	Line 48:         return $("#contentTable").length == 0;

No hits for Emails&action=DetailView

However, a general search on Emails&action=DetailView&record produced 9 hits in 7 files


D:\xampp\htdocs\suitecrm_immobilier\cache\smarty\templates_c\%%C9^C95^C95D1E90%%displaySubjectField.tpl.php (1 hit)
	Line 18:             <a href="index.php?module=Emails&action=DetailView&record=<?php echo $this->_tpl_vars['bean']['id']; ?>
  D:\xampp\htdocs\suitecrm_immobilier\modules\Emails\EmailsController.php (2 hits)
	Line 565:             header('location:index.php?module=Emails&action=DetailView&record=' . $result[0]->id);
	Line 586:                 header('location:index.php?module=Emails&action=DetailView&record=' . $importedEmailId);
  D:\xampp\htdocs\suitecrm_immobilier\modules\Emails\PessimisticLock.php (1 hit)
	Line 86: 			header('Location: index.php?module=Emails&action=DetailView&record='.$next->id);
  D:\xampp\htdocs\suitecrm_immobilier\modules\Emails\templates\displaySubjectField.tpl (1 hit)
	Line 54:             <a href="index.php?module=Emails&action=DetailView&record={$bean.id}">{$subject}</a>
  D:\xampp\htdocs\suitecrm_immobilier\upload\upgrades\patch\SuiteCRM-Upgrade-7.10-to-7.10.7-restore\modules\Emails\EmailsController.php (2 hits)
	Line 565:             header('location:index.php?module=Emails&action=DetailView&record=' . $result[0]->id);
	Line 586:                 header('location:index.php?module=Emails&action=DetailView&record=' . $importedEmailId);
  D:\xampp\htdocs\suitecrm_immobilier\upload\upgrades\patch\SuiteCRM-Upgrade-7.10-to-7.10.7-restore\modules\Emails\PessimisticLock.php (1 hit)
	Line 86: 			header('Location: index.php?module=Emails&action=DetailView&record='.$next->id);
  D:\xampp\htdocs\suitecrm_immobilier\upload\upgrades\patch\SuiteCRM-Upgrade-7.10-to-7.10.7-restore\modules\Emails\templates\displaySubjectField.tpl (1 hit)
	Line 54:             <a href="index.php?module=Emails&action=DetailView&record={$bean.id}">{$subject}</a>

I found out that the incriminated code is in \include\DetailView\header.tpl


<script language="javascript">
    {literal}
    SUGAR.util.doWhen(function () {
        return $("#contentTable").length == 0;
    }, SUGAR.themes.actionMenu);
    {/literal}
</script>

I removed it, saved, stopped/started server, made repair & rebuild,and it still appears in the console…

Update : the expression was totally removed from code.
It does not appear in cache tpl files anymore.
Console is now 100% clean.

Page still broken.

Since yesterday I now get only 1 error in php_error.log each time the cron task is running.


[05-Jul-2018 12:20:35 Europe/Berlin] PHP Notice:  Undefined property: User::$team_set_id in D:\xampp\htdocs\suitecrm_immobilier\modules\Schedulers\_AddJobsHere.php on line 96

Any idea of what could now break the page ?

There’s nothing wrong with having the “literal” tags in the TPL files, they belong there and have a function. But they should be interpreted as the HTML is built from them, and they shouldn’t appear on the final rendered page (I believe - I might be wrong).

Anyway that code is very generic, for all modules and for many screens, so I don’t think the fix is to remove it there. It’s probably a bug in the code building the Email screen from those TPLs.

I’m trying to get a developer to look at this but the hard part is that I don’t get this problem in my servers. Maybe it’s a XAMPP quirk, maybe it’s something about your email, some special characters like accents or brackets or quote marks…

I’m having the same issue (as noted in a separate thread) and I don’t have any special characters in the email and it happens in every email.

I’d like to ask everybody here in this thread:

Is your problem specific only when the logged in user is an admin, or only when it’s not an admin, or for every user?

I’m having the problem for every user, admin and regular users.

I just found the issue relating to the php code displaying on DetailView of emails.

Correct me if im wrong but i only saw reports of this happening on windows .

Anyways… when i reversed the change made to modules/Emails/vardefs.php on commit a60c60f1 (change emailbody back to html), ran a quick repair and checked, the detailview is working again in the email module

Thanks for that information @jamie. We need to get to the bottom of this, we can’t just remove that (it breaks something else), but at least we know where to look for the bug.

Can other people confirm if this is happening only on Windows?

Also, can you please check your php_errrors.log? If it’s a Windows problem, it’s probably this line because of some path problem. But this should give some indication in the log file:

https://github.com/salesagility/SuiteCRM/blob/master/include/SugarFields/Fields/EmailBody/SugarFieldEmailBody.php#L45

See issue 6131 for temp fix on xampp