CActiveDataProvider's totalItemCount returns wrong number

I run a complex query using CDbCriteria and fetch results as a CActiveDataProvider instance, but there is something strange going on, count($dataProvider->getData()) and $dataProvider->getTotalItemCount(); returns completely different numbers?

Looks like this is a bug in CActiveDataProvider and still not fixed, there is a hack though:

http://www.yiiframework.com/forum/index.php/topic/20910-cactivedataprovider-cdbcriteria-pagination-count-doesnt-match-number-of-records/page__p__102458__hl__cactivedataprovider+wrong+count#entry102458