Skip to content

vt721: count on non-countable warning generated in template file

See: https://code.vtiger.com/vtiger/vtigercrm/blob/master/layouts/v7/modules/Vtiger/ModuleRelatedTabs.tpl#L33

This line generates a PHP Warning when a DetailView record is loaded and the module doesn't have any related modules.

( ! ) Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/html/vt721-2/test/templates_c/v7/f908a6fc376e543c13e68ecca2f95ed4da06a0bf.file.ModuleRelatedTabs.tpl.php on line 62

This is because the line above it in the template file assumes that $DETAILVIEW_LINKS['DETAILVIEWRELATED']} will always be set.

But if you look at the getDetailViewLinks() method of the Vtiger_DetailView_Model, you can see that if $relationModels is empty, then 'DETAILVIEWRELATED' will be simply null or false.