Index: kernel/search/plugins/ezsearchengine/ezsearchengine.php
===================================================================
--- kernel/search/plugins/ezsearchengine/ezsearchengine.php	(revision 22601)
+++ kernel/search/plugins/ezsearchengine/ezsearchengine.php	(working copy)
@@ -1047,24 +1047,6 @@
                     $showInvisibleNodesCond
                     $sortWhereSQL
                     ORDER BY $orderByFieldsSQL";
-                if ( $tmpTableCount == 0 )
-                {
-                    $searchCountQuery = "SELECT count( DISTINCT ezcontentobject.id ) AS count
-                    FROM
-                       ezcontentobject,
-                       ezcontentclass,
-                       ezcontentobject_tree
-                       $versionNameTables
-                    WHERE
-                    $emptyWhere
-                    ezcontentobject.contentclass_id = ezcontentclass.id and
-                    ezcontentclass.version = '0' and
-                    ezcontentobject.id = ezcontentobject_tree.contentobject_id and
-                    ezcontentobject_tree.node_id = ezcontentobject_tree.main_node_id
-                    $versionNameJoins
-                    $showInvisibleNodesCond
-                    $sortWhereSQL";
-                }
             }
             else
             {
@@ -1085,31 +1067,30 @@
                     ezcontentobject_tree.node_id = ezcontentobject_tree.main_node_id
                     $versionNameJoins
                      ";
-                if ( $tmpTableCount == 0 )
-                {
-                    $searchCountQuery = "SELECT count( DISTINCT ezcontentobject.id ) AS count
-                    FROM
-                       ezcontentobject,
-                       ezcontentclass,
-                       ezcontentobject_tree
-                       $versionNameTables
-                    WHERE
-                    ezcontentobject.contentclass_id = ezcontentclass.id and
-                    ezcontentclass.version = '0' and
-                    ezcontentobject.id = ezcontentobject_tree.contentobject_id and
-                    ezcontentobject_tree.node_id = ezcontentobject_tree.main_node_id
-                    $versionNameJoins
-                     ";
-                }
             }
             // Count query
-            $where = "WHERE";
-            if ( $tmpTableCount == 1 )
-                $where = "";
-            if ( $tmpTableCount > 0 )
+            $languageCond = eZContentLanguage::languagesSQLFilter( 'ezcontentobject' );
+            if ( $tmpTableCount == 0 )
             {
-                $searchCountQuery = "SELECT count( * ) AS count FROM $tmpTablesFrom $where $tmpTablesWhere ";
+                $searchCountQuery = "SELECT count( DISTINCT ezcontentobject.id ) AS count
+                        FROM
+                           ezcontentobject,
+                           ezcontentobject_tree
+                        WHERE
+                        ezcontentobject.id = ezcontentobject_tree.contentobject_id and
+                        ezcontentobject_tree.node_id = ezcontentobject_tree.main_node_id
+                        AND $languageCond
+                        $showInvisibleNodesCond";
             }
+            else
+            {
+                $searchCountQuery = "SELECT count( DISTINCT ezcontentobject.id ) AS count
+                        FROM $tmpTablesFrom $tmpTablesSeparator
+                             ezcontentobject
+                        WHERE $tmpTablesWhere $and
+                            $tmpTablesWhereExtra
+                            $languageCond";
+            }
 
             $objectRes = array();
             $searchCount = 0;
