@@ -371,19 +371,21 @@ protected function getBareIndexNameFromReplicaSetting(string $replicaSetting): s
371
371
*
372
372
* @param array $replicasToDelete - which replicas to delete
373
373
* @param bool $waitLastTask - wait until deleting next replica (default: false)
374
- * @param bool $prevalidate - verify replica is not attached to a primary index before attempting to delete (default: false)
374
+ * @param bool $safeMode - ensure replica is not attached to a primary index before attempting to delete (default: false)
375
+ * @param int|null $storeId
375
376
* @return void
376
377
* @throws AlgoliaException
377
378
* @throws ExceededRetriesException
379
+ * @throws NoSuchEntityException
378
380
*/
379
381
protected function deleteReplicas (
380
382
array $ replicasToDelete ,
381
383
bool $ waitLastTask = false ,
382
- bool $ prevalidate = false ,
384
+ bool $ safeMode = false ,
383
385
?int $ storeId = null ): void
384
386
{
385
387
foreach ($ replicasToDelete as $ deletedReplica ) {
386
- $ this ->deleteReplica ($ deletedReplica , $ prevalidate );
388
+ $ this ->deleteReplica ($ deletedReplica , $ safeMode , $ storeId );
387
389
if ($ waitLastTask ) {
388
390
$ this ->algoliaHelper ->waitLastTask ($ storeId , $ deletedReplica );
389
391
}
@@ -393,11 +395,12 @@ protected function deleteReplicas(
393
395
/**
394
396
* @throws AlgoliaException
395
397
* @throws ExceededRetriesException
398
+ * @throws NoSuchEntityException
396
399
*/
397
- protected function deleteReplica (string $ replicaIndexName , bool $ precheck = false , ?int $ storeId = null ): void
400
+ protected function deleteReplica (string $ replicaIndexName , bool $ safeMode = false , ?int $ storeId = null ): void
398
401
{
399
- if ($ precheck ) {
400
- $ settings = $ this ->algoliaHelper ->getSettings ($ replicaIndexName );
402
+ if ($ safeMode ) {
403
+ $ settings = $ this ->algoliaHelper ->getSettings ($ replicaIndexName, $ storeId );
401
404
if (isset ($ settings [self ::ALGOLIA_SETTINGS_KEY_PRIMARY ])) {
402
405
$ this ->detachReplica ($ settings [self ::ALGOLIA_SETTINGS_KEY_PRIMARY ], $ replicaIndexName , $ storeId );
403
406
}
@@ -411,10 +414,11 @@ protected function deleteReplica(string $replicaIndexName, bool $precheck = fals
411
414
*
412
415
* @throws ExceededRetriesException
413
416
* @throws AlgoliaException
417
+ * @throws NoSuchEntityException
414
418
*/
415
419
protected function detachReplica (string $ primaryIndexName , string $ replicaIndexName , ?int $ storeId = null ): void
416
420
{
417
- $ settings = $ this ->algoliaHelper ->getSettings ($ primaryIndexName );
421
+ $ settings = $ this ->algoliaHelper ->getSettings ($ primaryIndexName, $ storeId );
418
422
if (!isset ($ settings [self ::ALGOLIA_SETTINGS_KEY_REPLICAS ])) {
419
423
return ;
420
424
}
0 commit comments