MailWatch 1.2.24 throws a fatal error on PHP 8.4 causing a blank page after login. The error appears in the PHP-FPM error log as:
PHP Fatal error: Uncaught TypeError: closedir(): Argument #1 ($dir_handle) must be of type resource or null, false given in /var/www/html/mailscanner/msmail.inc.php:38
The problem is in msmail.inc.php where closedir() is called outside the if (opendir()) block. In PHP 8.4, closedir() no longer accepts false as an argument — previously this was a warning, now it is a fatal error.
Fix:
In /var/www/html/mailscanner/msmail.inc.php, move closedir($handle) inside the if block:
php$queue = 0;
if ($handle = opendir($queuedir)) {
while (($file = readdir($handle)) !== false) {
if (!in_array($file, ['.', '..']) && !is_dir($queuedir . $file)) {
++$queue;
}
}
closedir($handle); // moved inside if block
}
return $queue;
No service restart required — the fix takes effect immediately on the next page load.
Rocky Linux 8.10
php-8.4.18-1.module_php.8.4.el8.remi.x86_64
php-fpm-8.4.18-1.module_php.8.4.el8.remi.x86_64
MailWatch 1.2.24 throws a fatal error on PHP 8.4 causing a blank page after login. The error appears in the PHP-FPM error log as:
PHP Fatal error: Uncaught TypeError: closedir(): Argument #1 ($dir_handle) must be of type resource or null, false given in /var/www/html/mailscanner/msmail.inc.php:38
The problem is in msmail.inc.php where closedir() is called outside the if (opendir()) block. In PHP 8.4, closedir() no longer accepts false as an argument — previously this was a warning, now it is a fatal error.
Fix:
In /var/www/html/mailscanner/msmail.inc.php, move closedir($handle) inside the if block:
php$queue = 0;
if ($handle = opendir($queuedir)) {
while (($file = readdir($handle)) !== false) {
if (!in_array($file, ['.', '..']) && !is_dir($queuedir . $file)) {
++$queue;
}
}
closedir($handle); // moved inside if block
}
return $queue;
No service restart required — the fix takes effect immediately on the next page load.
Rocky Linux 8.10
php-8.4.18-1.module_php.8.4.el8.remi.x86_64
php-fpm-8.4.18-1.module_php.8.4.el8.remi.x86_64