Related entities count not shown due to PHP Fatal error in Emails module
Symptom: Related entities count not shown over related entity tab's icon in detail view
LOG:
[Mon Feb 10 16:50:27.591560 2025] [proxy_fcgi:error] [pid 983609] [client 5.91.161.3:18560]
AH01071: Got error 'PHP message: PHP Fatal error: Uncaught TypeError: Cannot access offset of type string on string in modules/Emails/Emails.php:535
Stack trace:
#0 include/utils/UserInfoUtil.php(2315): Emails->getNonAdminAccessControlQuery()
#1 modules/Users/models/Privileges.php(173): getNonAdminAccessControlQuery()
#2 modules/Vtiger/models/Module.php(1567): Users_Privileges_Model::getNonAdminAccessControlQuery()
#3 modules/Vtiger/models/Module.php(1523): Vtiger_Module_Model->getNonAdminAccessControlQueryForRelation()
#4 modules/Project/models/Module.php(71): Vtiger_Module_Model->getRelationQuery()
#5 modules/Vtiger/models/Relation.php(123): Project_Module_Model->getRelationQuery()
#6 modules/Vtiger/models/RelationListView.php(442): Vtiger...', referer: index.php?module=Project&view=Detail&record=638&app=PROJECT
Cause: Array passed as String in:
if (!empty($sharingRuleInfo) && (php7_count($sharingRuleInfo['ROLE']) > 0 ||
php7_count($sharingRuleInfo['GROUP']) > 0)) {
...
}
Solution (quick and dirty without investigate upstream cause): Add a check before:
if(is_array($sharingRuleInfo)){
if (!empty($sharingRuleInfo) && (php7_count($sharingRuleInfo['ROLE']) > 0 ||
php7_count($sharingRuleInfo['GROUP']) > 0)) {
...
}
}