Index: branches/5.1.x/core/units/custom_data/custom_data_event_handler.php =================================================================== diff -u -N -r13168 -r13313 --- branches/5.1.x/core/units/custom_data/custom_data_event_handler.php (.../custom_data_event_handler.php) (revision 13168) +++ branches/5.1.x/core/units/custom_data/custom_data_event_handler.php (.../custom_data_event_handler.php) (revision 13313) @@ -1,6 +1,6 @@ saves 4 sqls queries - $cache_key = 'all_custom_fields[%CfSerial%][%ModSerial%]'; - $all_custom_fields = $this->Application->getCache($cache_key, false); + if ($no_caching) { + $all_custom_fields = $this->getCustomFields(); + } + else { + $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); + if ($all_custom_fields === false) { + $this->Conn->nextQueryCachable = true; + $all_custom_fields = $this->getCustomFields(); + $this->Application->setCache($cache_key, $all_custom_fields); + } } foreach ($all_custom_fields as $custom_field_id => $custom_field_data) { @@ -85,6 +88,22 @@ } /** + * Returns sorted list of all custom fields + * + * @return Array + */ + function getCustomFields() + { + $sql = 'SELECT * + FROM '.TABLE_PREFIX.'CustomField'; + $ret = $this->Conn->Query($sql, 'CustomFieldId'); + + ksort($ret); + + return $ret; + } + + /** * Fills cloned cdata config with data from it's parent * * @param kEvent $event