Ineffective event handling in DictionaryMetaFieldManager

Found in

EPiServer.Commerce 12.0.0

Fixed in

EPiServer.Commerce 12.17.0

Created

Jan 16 2019

Updated

Feb 18 2019

Area

Core

State

Closed, Fixed and tested


Description

DictionaryMetaFieldManager will try to load all metaclasses when a metafield is changed (linked/unlinked/updated), so it can update the list of dictionary type metafields. However, this is far from perfect:

  • A metafield is linked
  • GetCatalogMetaClasses is called, which calls to MetaClass.GetList
  • Inside MetaClass.GetList, for each metaclass, HandleRequiredFields is called, which effectively calls metaClass.AddFields multiple times.
  • AddFields will raise RaiseMetaFieldLinked event again.

In the end, MetaDataPlusDatabase.LoadMetaClassListByNamespace will be called many times (thousands or more).