Index: branches/5.2.x/core/kernel/db/dblist.php =================================================================== diff -u -N -r15727 -r16007 --- branches/5.2.x/core/kernel/db/dblist.php (.../dblist.php) (revision 15727) +++ branches/5.2.x/core/kernel/db/dblist.php (.../dblist.php) (revision 16007) @@ -1,6 +1,6 @@ TableName, $usage_string)); + $optimizer = new LeftJoinOptimizer($q, $this->replaceModePrefix( str_replace('%1$s', $this->TableName, $usage_string) )); $q = $optimizer->simplify(); } @@ -746,7 +746,12 @@ $where = $this->Application->makeClass('kMultipleFilter'); /* @var $where kMultipleFilter */ - $where->addFilter('system_where', $this->WhereFilter[self::FLT_SYSTEM] ); + if ( $for_counting ) { + $where->addFilter('system_where', $this->extractCalculatedFields($this->WhereFilter[self::FLT_SYSTEM]->getSQL()) ); + } + else { + $where->addFilter('system_where', $this->WhereFilter[self::FLT_SYSTEM] ); + } if (!$system_filters_only) { $where->addFilter('view_where', $this->WhereFilter[self::FLT_VIEW] );