From 75b824bced42f3da50748acb3b40e6b177775e64 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Tue, 26 Feb 2008 13:16:59 +0000 Subject: [PATCH] To improve performance for people/installations with large amounts of infologs and many customfields who want to use customfields in customized templates, but do not want to use the customfields in listview, reworked the logic of the retrieval of customfields. Fix for the retrieve more fields, than selected - problem, when customfields start with the same string. Replaced stripos by in_array after a split of the selected cols. --- infolog/inc/class.soinfolog.inc.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/infolog/inc/class.soinfolog.inc.php b/infolog/inc/class.soinfolog.inc.php index 383cb66c2f..19d80e0739 100644 --- a/infolog/inc/class.soinfolog.inc.php +++ b/infolog/inc/class.soinfolog.inc.php @@ -804,16 +804,24 @@ class soinfolog // DB-Layer $ids[$info['info_id']] = $info; } - if ($ids && $query['custom_fields']) + // prepare selected cols array + $sca=explode(',',$query['selectcols']); + if ($ids) { $this->db->select($this->extra_table,'*',array('info_id'=>array_keys($ids)),__LINE__,__FILE__); while ($row = $this->db->row(true)) { - if ((isset($row['info_extra_value'])&&strlen($row['info_extra_value'])>0) && - (stripos($query['selectcols'],'#'.$row['info_extra_name'])!==FALSE || !isset($query['selectcols']) || - (stripos($query['selectcols'],'#')===FALSE && stripos($query['selectcols'],'customfields')!==FALSE) )) + if ((isset($row['info_extra_value'])&&strlen($row['info_extra_value'])>0)) { - $ids[$row['info_id']]['#'.$row['info_extra_name']] = $row['info_extra_value']; + if ((in_array('#'.$row['info_extra_name'],$sca) || !isset($query['selectcols']) || + (stripos($query['selectcols'],'#')===FALSE && stripos($query['selectcols'],'customfields')!==FALSE) )) + { + $ids[$row['info_id']]['#'.$row['info_extra_name']] = $row['info_extra_value']; + } else { + if (!$query['custom_fields']) { + $ids[$row['info_id']]['#'.$row['info_extra_name']] = $row['info_extra_value']; + } + } } else { unset($ids[$row['info_id']]['#'.$row['info_extra_name']]); }