Index: branches/5.1.x/core/units/custom_data/custom_data_event_handler.php =================================================================== diff -u -N -r13086 -r13168 --- branches/5.1.x/core/units/custom_data/custom_data_event_handler.php (.../custom_data_event_handler.php) (revision 13086) +++ branches/5.1.x/core/units/custom_data/custom_data_event_handler.php (.../custom_data_event_handler.php) (revision 13168) @@ -1,6 +1,6 @@ saves 4 sqls queries - $sql = 'SELECT * - FROM '.TABLE_PREFIX.'CustomField'; - $all_custom_fields = $this->Conn->Query($sql, 'CustomFieldId'); - ksort($all_custom_fields); + $cache_key = 'all_custom_fields[%CfSerial%][%ModSerial%]'; + $all_custom_fields = $this->Application->getCache($cache_key, false); + + if ($all_custom_fields === false) { + $this->Conn->nextQueryCachable = true; + $sql = 'SELECT * + FROM '.TABLE_PREFIX.'CustomField'; + $all_custom_fields = $this->Conn->Query($sql, 'CustomFieldId'); + ksort($all_custom_fields); + + $this->Application->setCache($cache_key, $all_custom_fields); + } + foreach ($all_custom_fields as $custom_field_id => $custom_field_data) { $cf_type = $custom_field_data['Type']; if (!array_key_exists($cf_type, $custom_fields)) { @@ -168,6 +177,10 @@ $config_calculated_fields = $this->Application->getUnitOption($prefix, 'CalculatedFields', Array()); foreach ($config_calculated_fields as $special => $special_fields) { + if ($special == '-virtual') { + continue; + } + $config_calculated_fields[$special] = array_merge_recursive2($config_calculated_fields[$special], $calculated_fields); } $this->Application->setUnitOption($prefix, 'CalculatedFields', $config_calculated_fields);