@@ -50,10 +50,10 @@ public function createFindByQueryBuilder(array $criteria, ?array $orderBy): Quer
5050 $ this ->getPrefixedFields (['term_id ' , 'name ' , 'slug ' , 'taxonomy ' , 'term_taxonomy_id ' , 'count ' ]),
5151 );
5252
53- $ queryBuilder ->select ([
53+ $ queryBuilder ->select (
5454 ...$ this ->getPrefixedFields (['term_id ' , 'name ' , 'slug ' , 'taxonomy ' , 'term_taxonomy_id ' , 'count ' ]),
55- ...$ extraFields,
56- ] );
55+ ...$ extraFields
56+ );
5757 } else {
5858 foreach ($ this ->getPrefixedFields ($ selectedFields ) as $ field ) {
5959 if (!\in_array ($ field , $ groupByFields , true )) {
@@ -152,19 +152,21 @@ public function removeTermsFromEntity(BaseEntity $entity, array $terms): void
152152
153153 private function recountTerms (): void
154154 {
155+ $ tableName = $ this ->entityManager ->getTablesPrefix () . 'term_taxonomy ' ;
156+
155157 $ subSelect = $ this ->entityManager ->getConnection ()
156158 ->createQueryBuilder ()
157159 ->select ('COUNT(*) ' )
158160 ->from ($ this ->entityManager ->getTablesPrefix () . 'term_relationships ' , 'tr ' )
159161 ->leftJoin ('tr ' , $ this ->entityManager ->getTablesPrefix () . 'posts ' , 'p ' , 'p.id = tr.object_id ' )
160- ->where (' tr.term_taxonomy_id = tt .term_taxonomy_id ' )
161- ->andWhere ("tt .taxonomy NOT IN ('link_category') " )
162+ ->where (" tr.term_taxonomy_id = $ tableName .term_taxonomy_id " )
163+ ->andWhere ("$ tableName .taxonomy NOT IN ('link_category') " )
162164 ->andWhere ("p.post_status IN ('publish', 'future') " )
163165 ;
164166
165167 $ this ->entityManager ->getConnection ()
166168 ->createQueryBuilder ()
167- ->update ($ this -> entityManager -> getTablesPrefix () . ' term_taxonomy ' , ' tt ' )
169+ ->update ($ tableName )
168170 ->set ('count ' , sprintf ('(%s) ' , $ subSelect ->getSQL ()))
169171 ->executeStatement ()
170172 ;
0 commit comments