E_COMPILE_ERROR when enabling Magento compilation
-
16-10-2019 - |
Question
I'm trying to enable compilation on Magento via the control panel and while compilation is enabled the main page fails to display properly and I find that index.php has repeatedly raised the following error in logs:
E_COMPILE_ERROR: require_once(): Failed opening required 'ConfigFileManagerModel.php' (include_path='/var/www/vhosts/<domain_name_redacted>/httpdocs/includes/src:.:')
The site returns to normal immediately after disabling compilation but I'd really like to have the performance benefits. Does anyone know how to fix this?
Solution
It sounds like one of your extensions, or some custom code in your system, is incompatible with Magento's compilation mode. The exact solution will vary depending on your PHP system. Here's an explanation of the problem and some troubleshooting tips that should help you.
A file in your system contains a line that looks something like this
//the string 'ConfigFileManager-Model.php' may be
//a constant or variable as well
require_once 'ConfigFileManager-Model.php';
The file ConfigFileManager-Model.php
is not part of Magento, or any publicly distributed package as far as I can tell.
It sounds like when you're running in "non-compiled mode", Magento can find this file without issue. That means it's somewhere in the normal Magento include paths
/path/to/magento/app/code/core/ConfigFileManager-Model.php
/path/to/magento/app/code/community/ConfigFileManager-Model.php
/path/to/magento/app/code/local/ConfigFileManager-Model.php
/path/to/magento/path/to/calling/files/own/folder/ConfigFileManager-Model.php
#possibly more, depending on your system's default include path
However, when Magento runs in compiled mode, the core
, local
, and community
code pool paths are not added as include paths. Only the folder
/path/to/magento/includes/src
is added as an include path. Additionally, what compilation mode does is make copies of all the class files and drops them into the includes/src
folder. That means the file's own original folder is no longer in the include path. Because of this, when Magento runs the require
code in compilation mode, it can't find the ConfigFileManager-Model.php
file, and fails.
The best thing to do would be recode the module and/or custom code such that the functionality of ConfigFileManager-Model.php
is incorporated into a standard Magento helper of model class.
The less good, but quicker thing would be to identify all the places ConfigFileManager-Model.php
is required
and change the path so it's absolute instead of relative.