500 Error adding/editing Users & Reports

Your software
My Mautic version is: 2.16.2
My PHP version is: 7.2

Your problem
My problem is:
Out of the blue Mautic started giving a 500 internal server error whenever we try to either Add/Edit a User or Add/Edit new or existing Reports.

Additionally, I noticed this error [Symfony\Component\Debug\Exception\FatalThrowableError]
Call to a member function getEvent() on boolean
when running /app/console mautic:campaigns:trigger from the CLI.

These errors are showing in the log:

The error_log shows only the following messages which happened before we noticed any of these issues.

[24-Sep-2020 16:27:33 America/New_York] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/c7abc45/public_html/ourdomain.com/app/bundles/CoreBundle/Model/IteratorExportDataModel.php on line 71

[24-Sep-2020 16:27:33 America/New_York] PHP Warning: count(): Parameter must be an array or an object that implements Countable in /home/c7abc45/public_html/ourdomain.com/app/bundles/CoreBundle/Model/IteratorExportDataModel.php on line 72

The app/logs/log_files show a number of errors.

This is what shows up in the log file when adding/editing users

[2020-09-29 11:27:20] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: “An exception occurred while executing ‘INSERT INTO users (is_published, date_added, created_by, created_by_user, date_modified, modified_by, modified_by_user, checked_out, checked_out_by, checked_out_by_user, username, password, first_name, last_name, email, position, timezone, locale, last_login, last_active, online_status, preferences, signature, role_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)’ with params [1, “2020-09-29 15:27:20”, 1, “System Administrator”, null, null, null, null, null, null, “test.user”, “$2y$13$kTkqXUyFCywYqN2B4o3fhOQ9Qv6wrHsSTYbylab2ohHPCzdLV/Prq”, “Test”, “User”, “test@vtforge.com”, null, null, null, null, null, “offline”, “a:0:{}”, “Best regards, |FROM_NAME|”, 3]: SQLSTATE[HY000]: General error: 1364 Field ‘id’ doesn’t have a default value” at /home/c7abc45/public_html/ourdomain.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 115 {“exception”:"[object] (Doctrine\DBAL\Exception\DriverException(code: 0): An exception occurred while executing ‘INSERT INTO users (is_published, date_added, created_by, created_by_user, date_modified, modified_by, modified_by_user, checked_out, checked_out_by, checked_out_by_user, username, password, first_name, last_name, email, position, timezone, locale, last_login, last_active, online_status, preferences, signature, role_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)’ with params [1, “2020-09-29 15:27:20”, 1, “System Administrator”, null, null, null, null, null, null, “test.user”, “$2y$13$kTkqXUyFCywYqN2B4o3fhOQ9Qv6wrHsSTYbylab2ohHPCzdLV\/Prq”, “Test”, “User”, “test@vtforge.com”, null, null, null, null, null, “offline”, “a:0:{}”, “Best regards, |FROM_NAME|”, 3]:\n\nSQLSTATE[HY000]: General error: 1364 Field ‘id’ doesn’t have a default value at /home/c7abc45/public_html/ourdomain.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:115, Doctrine\DBAL\Driver\PDOException(code: HY000): SQLSTATE[HY000]: General error: 1364 Field ‘id’ doesn’t have a default value at /home/c7abc45/public_html/ourdomain.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:107, PDOException(code: HY000): SQLSTATE[HY000]: General error: 1364 Field ‘id’ doesn’t have a default value at /home/c7abc45/public_html/ourdomain.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:105)"}

This is what shows up in the log file when adding/editing Reports

[2020-09-29 12:01:06] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: “An exception occurred while executing ‘INSERT INTO reports (is_published, date_added, created_by, created_by_user, date_modified, modified_by, modified_by_user, checked_out, checked_out_by, checked_out_by_user, name, description, system, source, columns, filters, table_order, graphs, group_by, aggregators, settings, is_scheduled, schedule_unit, to_address, schedule_day, schedule_month_frequency) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)’ with params [1, “2020-09-29 16:01:06”, 1, “System Administrator”, null, null, null, null, null, null, “testererer”, null, 0, “leads”, “a:6:{i:0;s:12:“u.first_name”;i:1;s:11:“u.last_name”;i:2;s:10:“l.owner_id”;i:3;s:7:“l.email”;i:4;s:11:“l.firstname”;i:5;s:10:“l.lastname”;}”, “a:0:{}”, “a:0:{}”, “a:0:{}”, “a:0:{}”, “a:0:{}”, “{“showGraphsAboveTable”:0,“showDynamicFilters”:0,“hideDateRangeFilter”:0}”, 0, null, null, null, null]: SQLSTATE[HY000]: General error: 1364 Field ‘id’ doesn’t have a default value” at /home/c7abc45/public_html/ourdomain.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 115 {“exception”:"[object] (Doctrine\DBAL\Exception\DriverException(code: 0): An exception occurred while executing ‘INSERT INTO reports (is_published, date_added, created_by, created_by_user, date_modified, modified_by, modified_by_user, checked_out, checked_out_by, checked_out_by_user, name, description, system, source, columns, filters, table_order, graphs, group_by, aggregators, settings, is_scheduled, schedule_unit, to_address, schedule_day, schedule_month_frequency) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)’ with params [1, “2020-09-29 16:01:06”, 1, “System Administrator”, null, null, null, null, null, null, “testererer”, null, 0, “leads”, “a:6:{i:0;s:12:\“u.first_name\”;i:1;s:11:\“u.last_name\”;i:2;s:10:\“l.owner_id\”;i:3;s:7:\“l.email\”;i:4;s:11:\“l.firstname\”;i:5;s:10:\“l.lastname\”;}”, “a:0:{}”, “a:0:{}”, “a:0:{}”, “a:0:{}”, “a:0:{}”, “{\“showGraphsAboveTable\”:0,\“showDynamicFilters\”:0,\“hideDateRangeFilter\”:0}”, 0, null, null, null, null]:\n\nSQLSTATE[HY000]: General error: 1364 Field ‘id’ doesn’t have a default value at /home/c7abc45/public_html/ourdomain.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:115, Doctrine\DBAL\Driver\PDOException(code: HY000): SQLSTATE[HY000]: General error: 1364 Field ‘id’ doesn’t have a default value at /home/c7abc45/public_html/ourdomain.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:107, PDOException(code: HY000): SQLSTATE[HY000]: General error: 1364 Field ‘id’ doesn’t have a default value at /home/c7abc45/public_html/ourdomain.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:105)"}

This is a result of running /app/console mautic:campaigns:trigger

[2020-09-29 19:15:10] mautic.NOTICE: Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function getEvent() on boolean (uncaught exception) at /home/c7abc45/public_html/ourdomain.com/app/bundles/CampaignBundle/Executioner/ScheduledExecutioner.php line 315 while running console command mautic:campaigns:trigger

Additionally, these two errors are showing up repeatedly in the logs

[2020-09-29 11:27:18] mautic.ERROR: An exception occurred while executing ‘INSERT INTO page_hits (date_hit, date_left, country, region, city, isp, organization, code, referer, url, url_title, user_agent, remote_host, page_language, browser_languages, tracking_id, source, source_id, query, page_id, redirect_id, email_id, lead_id, ip_id, device_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)’ with params [“2020-09-29 15:27:18”, null, null, null, null, null, null, “200”, null, null, null, null, null, null, “a:0:{}”, “r66k49mwjd3otteatra6hxy”, null, null, “a:12:{s:10:“page_title”;s:29:“Products \u2013 Hubbardton Forge”;s:13:“page_language”;s:5:“en-US”;s:13:“page_referrer”;s:23:“www.hubbardtonforge.com”;s:8:“page_url”;s:48:“https://www.hubbardtonforge.com/filter/?q=PLANAR";s:7:“counter”;s:1:“0”;s:16:“mautic_device_id”;s:23:“r66k49mwjd3otteatra6hxy”;s:10:“resolution”;s:9:“1920x1080”;s:15:“timezone_offset”;s:3:“240”;s:8:“platform”;s:5:“Win32”;s:12:“do_not_track”;s:7:“unknown”;s:7:“adblock”;s:5:“false”;s:11:“fingerprint”;s:32:“1612a0f2f2a12595615cee68f7054ea8”;}", null, null, null, null, 1788, 115771]: SQLSTATE[HY000]: General error: 1364 Field ‘id’ doesn’t have a default value {“exception”:”[object] (Doctrine\DBAL\Exception\DriverException(code: 0): An exception occurred while executing ‘INSERT INTO page_hits (date_hit, date_left, country, region, city, isp, organization, code, referer, url, url_title, user_agent, remote_host, page_language, browser_languages, tracking_id, source, source_id, query, page_id, redirect_id, email_id, lead_id, ip_id, device_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)’ with params [“2020-09-29 15:27:18”, null, null, null, null, null, null, “200”, null, null, null, null, null, null, “a:0:{}”, “r66k49mwjd3otteatra6hxy”, null, null, “a:12:{s:10:\“page_title\”;s:29:\“Products \u2013 Hubbardton Forge\”;s:13:\“page_language\”;s:5:\“en-US\”;s:13:\“page_referrer\”;s:23:\“www.hubbardtonforge.com\”;s:8:\“page_url\”;s:48:\“https:\/\/www.hubbardtonforge.com\/filter\/?q=PLANAR\”;s:7:\“counter\”;s:1:\“0\”;s:16:\“mautic_device_id\”;s:23:\“r66k49mwjd3otteatra6hxy\”;s:10:\“resolution\”;s:9:\“1920x1080\”;s:15:\“timezone_offset\”;s:3:\“240\”;s:8:\“platform\”;s:5:\“Win32\”;s:12:\“do_not_track\”;s:7:\“unknown\”;s:7:\“adblock\”;s:5:\“false\”;s:11:\“fingerprint\”;s:32:\“1612a0f2f2a12595615cee68f7054ea8\”;}”, null, null, null, null, 1788, 115771]:\n\nSQLSTATE[HY000]: General error: 1364 Field ‘id’ doesn’t have a default value at /home/c7abc45/public_html/ourdomain.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:115, Doctrine\DBAL\Driver\PDOException(code: HY000): SQLSTATE[HY000]: General error: 1364 Field ‘id’ doesn’t have a default value at /home/c7abc45/public_html/ourdomain.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:107, PDOException(code: HY000): SQLSTATE[HY000]: General error: 1364 Field ‘id’ doesn’t have a default value at /home/c7abc45/public_html/ourdomain.com/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:105)”}

[2020-09-29 11:27:18] mautic.CRITICAL: Uncaught PHP Exception Doctrine\ORM\ORMException: “The EntityManager is closed.” at /home/c7abc45/public_html/ourdomain.com/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php line 144 {“exception”:"[object] (Doctrine\ORM\ORMException(code: 0): The EntityManager is closed. at /home/c7abc45/public_html/ourdomain.com/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php:144)"}

Steps I have tried to fix the problem:

I’m not even sure where to start with this, and suggestions would be greatly appreciated.

Here’s a clue I found.

This is how I solved the Doctrine “The EntityManager is closed.” issue. Basically each time there’s an exception (i.e. duplicate key) or not providing data for a mandatory column will cause Doctrine to close the Entity Manager.

I suspect you’re dealing with Mautic trying to insert a duplicate or invalid key into your database where that key should be unique. This could be a id or foreign id field.

Have you updated your version of PHP or Mysql just before this error started?