[BUG] Theme with invalid config.json breaks entire Themes section in Mautic 5.x - Critical Error ThemeHelper::shouldLoadTheme()

Here’s a bug report following the template for your Mautic theme issue:

Your software
My Mautic version is: 5.x
My PHP version is: 8.2.26
My Database type and version is: 10.11.10-MariaDB-ubu2204

Your problem
My problem is: The themes section in Mautic becomes inaccessible after uploading a custom theme. When trying to access the themes section, Mautic throws a critical error. Additionally, uploading new themes fails with a TypeError regarding null config.

These errors are showing in the log:

[2024-12-14T19:05:37.530306+00:00] mautic.CRITICAL: Uncaught PHP Exception TypeError: "Mautic\CoreBundle\Helper\ThemeHelper::shouldLoadTheme(): Argument #1 ($config) must be of type array, null given, called in /var/www/vhosts/chop.de/mautic/web/app/bundles/CoreBundle/Helper/ThemeHelper.php on line 493" at /var/www/vhosts/chop.de/mautic/web/app/bundles/CoreBundle/Helper/ThemeHelper.php line 526 {"exception":"[object] (TypeError(code: 0): Mautic\\CoreBundle\\Helper\\ThemeHelper::shouldLoadTheme(): Argument #1 ($config) must be of type array, null given, called in /var/www/vhosts/chop.de/mautic/web/app/bundles/CoreBundle/Helper/ThemeHelper.php on line 493 at /var/www/vhosts/chop.de/mautic/web/app/bundles/CoreBundle/Helper/ThemeHelper.php:526)"} {"hostname":"lycana.chop.de","pid":1020531}

Steps I have tried to fix the problem:

  • Verified JSON syntax of config.json
  • Checked file permissions
  • Attempted to reupload the theme
  • Cleared Mautic cache

The only solution currently is to manually delete the theme directory from the filesystem at themes/[theme-name] since the themes section in the UI is inaccessible due to this error.

This appears to be a bug in Mautic’s theme handling where an invalid or unreadable config.json file in a theme not only prevents that theme from loading but also breaks the entire themes section of Mautic, requiring filesystem-level intervention to resolve.