Description:
When viewing CDR details and call flow in the FusionPBX UI, the following fatal error occurs:
Steps to Reproduce:
Suggested Fix:
Add a type check before calling count(), for example:
or wherever count() is used:
Should be:
Request:
Please update the code to include this type check to prevent fatal errors when call_flow is null or not an array.
Environment:
~b10
When viewing CDR details and call flow in the FusionPBX UI, the following fatal error occurs:
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/fusionpbx/app/xml_cdr/resources/classes/xml_cdr.php:1449
Stack trace:
#0 /var/www/fusionpbx/app/xml_cdr/xml_cdr_details.php(285): xml_cdr->call_flow_summary()
#1 {main}
thrown in /var/www/fusionpbx/app/xml_cdr/resources/classes/xml_cdr.php on line 1449
Steps to Reproduce:
- Import CDRs (all call_flow fields are valid JSON arrays, e.g. '[]').
- Click on a CDR to view details and call flow.
- Observe the fatal error.
- All call_flow values in the database are valid JSON arrays ('[]'), not NULL.
- No other fields (json, xml) are NULL.
- The error persists even with clean, valid data.
Suggested Fix:
Add a type check before calling count(), for example:
$call_flow = json_decode($row['call_flow'], true);
$count = is_array($call_flow) ? count($call_flow) : 0;
or wherever count() is used:
count($value)
Should be:
is_array($value) ? count($value) : 0
Request:
Please update the code to include this type check to prevent fatal errors when call_flow is null or not an array.
Environment:
- FusionPBX version: 5.3.8
- PHP version: 8.1
- Database: PostgreSQL
~b10