Question

So, after some painful debugging (and enabling scream in xdebug), I was able to discover that some pages are returning a fatal error (such as catalog/product/gallery/id/155/image/202/) where Magento seems to be including the same class twice. I haven't yet figured out whats going on as I am not yet too familiar with the compilation internals

but I did discover that deleting the particular class in includes/src/__catalog.php just causes different classes to have the error, and deleting that entire file fixes the issue (but i lose all that compiled code).

I have tried to recompile the code with no luck on improving this issue.

I do prefer to leave code compilation enabled, because from an IO perspective, it does increase performance quite a bit.

I guess I am unsure as why the class is being included twice? I assume there is some logic messed up in the Autoloader that isnt detecting that the class is already loaded when it tries to load it again? Although it doesnt seem to have problems on other pages.

greping for existing classes shows:

$ grep -irn mage_catalog_block_breadcrumbs .
./app/code/core/Mage/Catalog/Block/Breadcrumbs.php:34:class Mage_Catalog_Block_Breadcrumbs extends Mage_Core_Block_Template
./app/code/core/Mage/Catalog/Block/Breadcrumbs.php:51:     * @return Mage_Catalog_Block_Breadcrumbs
./app/code/core/Mage/Compiler/etc/compilation.xml:231:            <Mage_Catalog_Block_Breadcrumbs/>
./includes/src/Mage_Catalog_Block_Breadcrumbs.php:34:class Mage_Catalog_Block_Breadcrumbs extends Mage_Core_Block_Template
./includes/src/Mage_Catalog_Block_Breadcrumbs.php:51:     * @return Mage_Catalog_Block_Breadcrumbs
./includes/src/__catalog.php:35:class Mage_Catalog_Block_Breadcrumbs extends Mage_Core_Block_Template
./includes/src/__catalog.php:52:     * @return Mage_Catalog_Block_Breadcrumbs

error:

PHP Fatal error:  Cannot redeclare class Mage_Catalog_Block_Breadcrumb in /var/www/vhosts/site/gitrepo/pti/magento/includes/src/__catalog.php on line 238
Jul 12 07:03:29  httpd: PHP Stack trace:
Jul 12 07:03:29  httpd: PHP   1. {main}() /var/www/vhosts/site/gitrepo/pti/magento/index.php:0
Jul 12 07:03:29  httpd: PHP   2. Mage::run() /var/www/vhosts/site/gitrepo/pti/magento/index.php:90
Jul 12 07:03:29  httpd: PHP   3. Mage_Core_Model_App->run() /var/www/vhosts/site/gitrepo/pti/magento/app/Mage.php:683
Jul 12 07:03:29  httpd: PHP   4. Mage_Core_Controller_Varien_Front->dispatch() /var/www/vhosts/site/gitrepo/pti/magento/includes/src/__default.php:20061
Jul 12 07:03:29  httpd: PHP   5. Mage_Core_Controller_Varien_Router_Standard->match() /var/www/vhosts/site/gitrepo/pti/magento/includes/src/__default.php:17484
Jul 12 07:03:29  httpd: PHP   6. Mage_Core_Controller_Varien_Action->dispatch() /var/www/vhosts/site/gitrepo/pti/magento/includes/src/__default.php:17927
Jul 12 07:03:29  httpd: PHP   7. Mage_Core_Controller_Front_Action->preDispatch() /var/www/vhosts/site/gitrepo/pti/magento/includes/src/__default.php:13571
Jul 12 07:03:29  httpd: PHP   8. Mage_Core_Controller_Varien_Action->preDispatch() /var/www/vhosts/site/gitrepo/pti/magento/includes/src/__default.php:14324
Jul 12 07:03:29  httpd: PHP   9. Varien_Autoload::registerScope() /var/www/vhosts/site/gitrepo/pti/magento/includes/src/__default.php:13689
Was it helpful?

Solution

Magento doesn't clear the caches when enabling compiling. If you dont clear the caches Magento will still remember where the files should be, but that conflicts with the compiled version.

So clear all the caches (magento, apc, memcached, what else you got) should fix this problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top