Skip to content

Commit 97e200d

Browse files
Fixed eav_config_entity throwing error message on removed entity model (#3338)
* fix eav_config_entity throwing error message on removed entity model * fix phpcs * fix exception message capitalization * fix log message capitalization --------- Co-authored-by: Fabrizio Balliano <[email protected]>
1 parent b4cee73 commit 97e200d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

app/code/core/Mage/Eav/Model/Config.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,23 @@ protected function _loadEntityTypes()
186186
$this->_entityTypes = [];
187187
$this->_entityTypeByCode = [];
188188
$entityTypeCollection = Mage::getResourceModel('eav/entity_type_collection');
189+
189190
/** @var Mage_Eav_Model_Entity_Type $entityType */
190191
foreach ($entityTypeCollection as $entityType) {
192+
// Ensure eav entity type model class is defined, otherwise skip processing it.
193+
// This check prevents leftover eav_entity_type entries from disabled/removed modules creating errors and
194+
// is necessary because the entire EAV model is now loaded eagerly for performance optimization.
195+
$entityModelClass = $entityType['entity_model'];
196+
$fqEntityModelClass = Mage::getConfig()->getModelClassName($entityModelClass);
197+
if (!class_exists($fqEntityModelClass)) {
198+
if (Mage::getIsDeveloperMode()) {
199+
throw new Exception('Failed loading of eav entity type because it does not exist: ' . $entityModelClass);
200+
} else {
201+
Mage::log('Skipped loading of eav entity type because it does not exist: ' . $entityModelClass);
202+
}
203+
continue;
204+
}
205+
191206
$this->_entityTypes[$entityType->getId()] = $entityType;
192207
$this->_entityTypeByCode[$entityType->getEntityTypeCode()] = $entityType;
193208
}

0 commit comments

Comments
 (0)