1818use CustomerManagementFrameworkBundle \Listing \Filter \AbstractFilter ;
1919use CustomerManagementFrameworkBundle \Listing \Filter \OnCreateQueryFilterInterface ;
2020use CustomerManagementFrameworkBundle \Service \MariaDb ;
21+ use Doctrine \DBAL \ArrayParameterType ;
22+ use Doctrine \DBAL \Connection ;
23+ use Doctrine \DBAL \ParameterType ;
2124use Doctrine \DBAL \Query \QueryBuilder ;
25+ use Exception ;
26+ use InvalidArgumentException ;
2227use Pimcore \Model \DataObject ;
2328use Pimcore \Model \DataObject \Listing as CoreListing ;
2429
@@ -119,7 +124,7 @@ protected function addCustomerSegment(DataObject\CustomerSegment $segment)
119124 {
120125 if ($ segment ->getGroup () && null !== $ this ->segmentGroup ) {
121126 if ($ segment ->getGroup ()->getId () !== $ this ->segmentGroup ->getId ()) {
122- throw new \ InvalidArgumentException ('Segment does not belong to the defined segment group ' );
127+ throw new InvalidArgumentException ('Segment does not belong to the defined segment group ' );
123128 }
124129 }
125130
@@ -187,6 +192,7 @@ protected function applyAndQuery(CoreListing\Concrete $listing, QueryBuilder $qu
187192 *
188193 * @param string $joinName
189194 * @param int|array $conditionValue
195+ * @throws Exception
190196 */
191197 protected function addJoin (
192198 CoreListing \Concrete $ listing ,
@@ -212,21 +218,25 @@ protected function addJoin(
212218 );
213219
214220 $ condition = $ baseCondition ;
215-
221+ $ valuePlaceholder = $ joinName . '_value ' ;
222+ $ parameterType = ParameterType::INTEGER ;
216223 if ($ this ->type === self ::OPERATOR_OR ) {
217224 // must match any of the passed IDs
218225 $ condition .= sprintf (
219226 ' AND %1$s.dest_id IN (%2$s) ' ,
220227 $ joinName ,
221- implode ( ' , ' , $ conditionValue )
228+ ' : ' . $ valuePlaceholder
222229 );
230+ $ value = array_keys ($ conditionValue );
231+ $ parameterType = ArrayParameterType::INTEGER ;
223232 } else {
224233 // runs an extra join for every ID - all joins must match
225234 $ condition .= sprintf (
226235 ' AND %1$s.dest_id = %2$s ' ,
227236 $ joinName ,
228- $ conditionValue
237+ ' : ' . $ valuePlaceholder
229238 );
239+ $ value = $ conditionValue ;
230240 }
231241
232242 $ queryBuilder ->join (
@@ -235,5 +245,7 @@ protected function addJoin(
235245 $ joinName ,
236246 $ condition
237247 );
248+
249+ $ queryBuilder ->setParameter ($ valuePlaceholder , $ value , $ parameterType );
238250 }
239251}
0 commit comments