@@ -561,12 +561,18 @@ public function getAllBySearchCriteria(array $searchCriteria, string $sort = 'st
561561 });
562562 }
563563
564- if (isset ($ searchCriteria ['sprint ' ]) && $ searchCriteria ['sprint ' ] > 0 && $ searchCriteria ['sprint ' ] != 'all ' ) {
565- $ sprintIds = explode (', ' , $ searchCriteria ['sprint ' ]);
566- $ query ->whereIn ('zp_tickets.sprint ' , $ sprintIds );
564+ if (isset ($ searchCriteria ['sprint ' ]) && $ searchCriteria ['sprint ' ] !== '' && $ searchCriteria ['sprint ' ] !== 'backlog ' ) {
565+ $ sprintIds = array_values (array_filter (
566+ array_map ('trim ' , explode (', ' , (string ) $ searchCriteria ['sprint ' ])),
567+ static fn ($ token ) => ctype_digit ($ token ) && (int ) $ token > 0
568+ ));
569+
570+ if ($ sprintIds !== []) {
571+ $ query ->whereIn ('zp_tickets.sprint ' , array_map ('intval ' , $ sprintIds ));
572+ }
567573 }
568574
569- if (isset ($ searchCriteria ['sprint ' ]) && $ searchCriteria ['sprint ' ] == 'backlog ' ) {
575+ if (isset ($ searchCriteria ['sprint ' ]) && $ searchCriteria ['sprint ' ] === 'backlog ' ) {
570576 $ query ->where (function ($ q ) {
571577 $ q ->whereNull ('zp_tickets.sprint ' )
572578 ->orWhere ('zp_tickets.sprint ' , 0 )
@@ -1224,15 +1230,22 @@ public function getAllMilestones(array $searchCriteria, string $sort = 'standard
12241230 });
12251231 }
12261232
1227- if (isset ($ searchCriteria ['sprint ' ]) && $ searchCriteria ['sprint ' ] > 0 && $ searchCriteria ['sprint ' ] != 'all ' ) {
1228- $ sprintIds = explode (', ' , $ searchCriteria ['sprint ' ]);
1229- $ query ->where (function ($ q ) use ($ sprintIds ) {
1230- $ q ->whereIn ('zp_tickets.sprint ' , $ sprintIds )
1231- ->orWhere ('zp_tickets.type ' , 'milestone ' );
1232- });
1233+ if (isset ($ searchCriteria ['sprint ' ]) && $ searchCriteria ['sprint ' ] !== '' && $ searchCriteria ['sprint ' ] !== 'backlog ' ) {
1234+ $ sprintIds = array_values (array_filter (
1235+ array_map ('trim ' , explode (', ' , (string ) $ searchCriteria ['sprint ' ])),
1236+ static fn ($ token ) => ctype_digit ($ token ) && (int ) $ token > 0
1237+ ));
1238+
1239+ if ($ sprintIds !== []) {
1240+ $ intSprintIds = array_map ('intval ' , $ sprintIds );
1241+ $ query ->where (function ($ q ) use ($ intSprintIds ) {
1242+ $ q ->whereIn ('zp_tickets.sprint ' , $ intSprintIds )
1243+ ->orWhere ('zp_tickets.type ' , 'milestone ' );
1244+ });
1245+ }
12331246 }
12341247
1235- if (isset ($ searchCriteria ['sprint ' ]) && $ searchCriteria ['sprint ' ] == 'backlog ' ) {
1248+ if (isset ($ searchCriteria ['sprint ' ]) && $ searchCriteria ['sprint ' ] === 'backlog ' ) {
12361249 $ query ->where (function ($ q ) {
12371250 $ q ->whereNull ('zp_tickets.sprint ' )
12381251 ->orWhere ('zp_tickets.sprint ' , 0 )
0 commit comments