mailwatch / MailWatch

MailWatch for MailScanner is a web-based front-end to MailScanner
http://mailwatch.org/
GNU General Public License v2.0
117 stars 66 forks source link

PHP Fatal error: Uncaught Error: Class 'database' not found in functions.php #1247

Closed LuisCardenasSolis closed 2 years ago

LuisCardenasSolis commented 2 years ago

Error to start Mailwatch : Class 'database' not found

https://github.com/mailwatch/MailWatch/blob/247d92fef35c7d77ea39d8b2003bd25069d96a41/mailscanner/functions.php#L69 https://github.com/mailwatch/MailWatch/blob/247d92fef35c7d77ea39d8b2003bd25069d96a41/mailscanner/functions.php#L103

The code in line 69 of the functions.php file indirectly uses the database class that comes from importing the database.php file. The checkLangCode() function makes use of the audit_log() function, which requires the dbconn() function, which would only work with the database class already imported, but it is still called on line 103, causing the error "PHP Fatal error: Uncaught Error : Class 'database' not found in /var/www/html/mailscanner/functions.php"

The workaround is to move the database.php file import to the top (after conf.php import: line 41)

require_once __DIR__ . '/conf.php';
require_once __DIR__ . '/database.php';