Skip to content

PHP8: PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given #20323

@mattmary

Description

@mattmary

One of the plugin user has a Fatal error in Matomo.

PHP Fatal error:  Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /nas/content/live/careatprod/wp-content/plugins/matomo/app/core/Filesystem.php:154 Stack trace: 
#0 /nas/content/live/careatprod/wp-content/plugins/matomo/app/core/Filesystem.php(154): count(NULL) 
#1 /nas/content/live/careatprod/wp-content/plugins/matomo/app/plugins/Diagnostics/Diagnostic/NfsDiskCheck.php(36): Piwik\Filesystem::checkIfFileSystemIsNFS() 
#2 /nas/content/live/careatprod/wp-content/plugins/matomo/app/plugins/Diagnostics/DiagnosticService.php(68): Piwik\Plugins\Diagnostics\Diagnostic\NfsDiskCheck->execute() 
#3 /nas/content/live/careatprod/wp-content/plugins/matomo/app/plugins/Diagnostics/DiagnosticService.php(54): Piwik\Plugins\Diagnostics\DiagnosticService->run(Array) 
#4 /nas/content/live/careatprod/wp-content/plugins/matomo/classes/WpMatomo/Admin/SystemReport.php(401): Piwik\Plugins\Diagnostics\DiagnosticService->runDiagnostics() 
#5 /nas/content/live/careatprod/wp-content/plugins/matomo/classes/WpMatomo/Admin/SystemReport.php(240): WpMatomo\Admin\SystemReport->get_matomo_info() 
#6 /nas/content/live/careatprod/wp-includes/class-wp-hook.php(308): WpMatomo\Admin\SystemReport->show('') 
#7 /nas/content/live/careatprod/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters('', Array) 
#8 /nas/content/live/careatprod/wp-includes/plugin.php(517): WP_Hook->do_action(Array) 
#9 /nas/content/live/careatprod/wp-admin/admin.php(259): do_action('matomo-analytic...') 
#10 {main} thrown in /nas/content/live/careatprod/wp-content/plugins/matomo/app/core/Filesystem.php on line 154 

Expected Behavior

No Fatal error.

Current Behavior

Possible Solution

cast $output as array after the exec command.
$output = (array) $output;

Steps to Reproduce (for Bugs)

Context

Your Environment

  • Matomo Version: 4.12.0
  • PHP Version: 8
  • Server Operating System:
  • Additionally installed plugins:
  • Browser:
  • Operating System:

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugFor errors / faults / flaws / inconsistencies etc.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions