Skip to content

Commit f748028

Browse files
committed
MAGE-1251 Fix replica detach logic
1 parent 01c4add commit f748028

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Service/Product/ReplicaManager.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,16 @@ protected function detachReplica(string $primaryIndexName, string $replicaIndexN
413413
*/
414414
protected function removeReplicaFromReplicaSetting(array $replicaSetting, string $replicaToRemove): array
415415
{
416-
return array_filter(
417-
$replicaSetting,
418-
function ($replicaIndexSetting) use ($replicaToRemove) {
419-
$escaped = preg_quote($replicaToRemove);
420-
$regex = '/^' . $escaped . '|virtual\(' . $escaped . '\)$/';
421-
return !preg_match($regex, $replicaToRemove);
422-
}
416+
$escaped = preg_quote($replicaToRemove);
417+
$regex = '/^' . $escaped . '|virtual\(' . $escaped . '\)$/';
418+
419+
return array_values(
420+
array_filter(
421+
$replicaSetting,
422+
function ($replicaIndexSetting) use ($regex) {
423+
return !preg_match($regex, $replicaIndexSetting);
424+
}
425+
)
423426
);
424427
}
425428

0 commit comments

Comments
 (0)