Skip to content

Commit ee4f8e7

Browse files
committed
MAGE-848 Clearly identify legacy virtual replica configuration path
1 parent 24d7fcd commit ee4f8e7

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Console/Command/ReplicaDisableVirtualCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected function disableVirtualReplicasForStore(int $storeId): bool
111111
$isStoreScoped = false;
112112

113113
if ($this->configChecker->isSettingAppliedForScopeAndCode(
114-
ConfigHelper::USE_VIRTUAL_REPLICA_ENABLED,
114+
ConfigHelper::LEGACY_USE_VIRTUAL_REPLICA_ENABLED,
115115
ScopeInterface::SCOPE_STORES,
116116
$storeId)
117117
) {
@@ -138,7 +138,7 @@ protected function disableVirtualReplicasForStore(int $storeId): bool
138138

139139
protected function disableVirtualReplicasForAllStores(): void
140140
{
141-
$this->configChecker->checkAndApplyAllScopes(ConfigHelper::USE_VIRTUAL_REPLICA_ENABLED, [$this, 'removeLegacyVirtualReplicaConfig']);
141+
$this->configChecker->checkAndApplyAllScopes(ConfigHelper::LEGACY_USE_VIRTUAL_REPLICA_ENABLED, [$this, 'removeLegacyVirtualReplicaConfig']);
142142

143143
$this->configChecker->checkAndApplyAllScopes(ConfigHelper::SORTING_INDICES, [$this, 'disableVirtualReplicaSortConfig']);
144144

@@ -149,12 +149,12 @@ protected function disableVirtualReplicasForAllStores(): void
149149

150150
public function removeLegacyVirtualReplicaConfig(string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, int $scopeId = 0): void
151151
{
152-
$value = $this->scopeConfig->getValue(ConfigHelper::USE_VIRTUAL_REPLICA_ENABLED, $scope, $scopeId);
152+
$value = $this->scopeConfig->getValue(ConfigHelper::LEGACY_USE_VIRTUAL_REPLICA_ENABLED, $scope, $scopeId);
153153
if (is_null($value)) {
154154
return;
155155
}
156-
$this->output->writeln("<info>Removing legacy configuration " . ConfigHelper::USE_VIRTUAL_REPLICA_ENABLED . " for $scope scope" . ($scope != ScopeConfigInterface::SCOPE_TYPE_DEFAULT ? " (ID=$scopeId)" : "") . "</info>");
157-
$this->configWriter->delete(ConfigHelper::USE_VIRTUAL_REPLICA_ENABLED, $scope, $scopeId);
156+
$this->output->writeln("<info>Removing legacy configuration " . ConfigHelper::LEGACY_USE_VIRTUAL_REPLICA_ENABLED . " for $scope scope" . ($scope != ScopeConfigInterface::SCOPE_TYPE_DEFAULT ? " (ID=$scopeId)" : "") . "</info>");
157+
$this->configWriter->delete(ConfigHelper::LEGACY_USE_VIRTUAL_REPLICA_ENABLED, $scope, $scopeId);
158158
}
159159

160160
public function disableVirtualReplicaSortConfig(string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, int $scopeId = 0): void

Helper/ConfigHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class ConfigHelper
141141
protected const IS_LOOKING_SIMILAR_ENABLED_IN_PDP = 'algoliasearch_recommend/recommend/looking_similar/is_looking_similar_enabled_on_pdp';
142142
protected const IS_LOOKING_SIMILAR_ENABLED_IN_SHOPPING_CART = 'algoliasearch_recommend/recommend/looking_similar/is_looking_similar_enabled_on_cart_page';
143143
protected const LOOKING_SIMILAR_TITLE = 'algoliasearch_recommend/recommend/looking_similar/title';
144-
public const USE_VIRTUAL_REPLICA_ENABLED = 'algoliasearch_instant/instant/use_virtual_replica'; //legacy config
144+
public const LEGACY_USE_VIRTUAL_REPLICA_ENABLED = 'algoliasearch_instant/instant/use_virtual_replica';
145145
protected const AUTOCOMPLETE_KEYBORAD_NAVIAGATION = 'algoliasearch_autocomplete/autocomplete/navigator';
146146
protected const FREQUENTLY_BOUGHT_TOGETHER_TITLE = 'algoliasearch_recommend/recommend/frequently_bought_together/title';
147147
protected const RELATED_PRODUCTS_TITLE = 'algoliasearch_recommend/recommend/related_product/title';

Setup/Patch/Data/MigrateVirtualReplicaConfigPatch.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function apply(): PatchInterface
4747
{
4848
$this->moduleDataSetup->getConnection()->startSetup();
4949

50-
$this->configChecker->checkAndApplyAllScopes(ConfigHelper::USE_VIRTUAL_REPLICA_ENABLED, [$this, 'migrateSetting']);
50+
$this->configChecker->checkAndApplyAllScopes(ConfigHelper::LEGACY_USE_VIRTUAL_REPLICA_ENABLED, [$this, 'migrateSetting']);
5151

5252
$this->moduleDataSetup->getConnection()->endSetup();
5353

@@ -65,14 +65,14 @@ public function apply(): PatchInterface
6565
public function migrateSetting(string $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT, int $scopeId = 0): void
6666
{
6767
// If not enabled - delete this old setting and move on...
68-
if (!$this->scopeConfig->isSetFlag(ConfigHelper::USE_VIRTUAL_REPLICA_ENABLED, $scope, $scopeId)) {
68+
if (!$this->scopeConfig->isSetFlag(ConfigHelper::LEGACY_USE_VIRTUAL_REPLICA_ENABLED, $scope, $scopeId)) {
6969
$this->deleteLegacyConfig($scope, $scopeId);
7070
return;
7171
}
7272

7373
// Get all stores affected by this configuration
7474
$storeIds = $this->configChecker->getAffectedStoreIds(
75-
ConfigHelper::USE_VIRTUAL_REPLICA_ENABLED,
75+
ConfigHelper::LEGACY_USE_VIRTUAL_REPLICA_ENABLED,
7676
$scope,
7777
$scopeId
7878
);
@@ -126,7 +126,7 @@ public function migrateSetting(string $scope = ScopeConfigInterface::SCOPE_TYPE_
126126

127127
protected function deleteLegacyConfig($scope, $scopeId): void
128128
{
129-
$this->configWriter->delete(ConfigHelper::USE_VIRTUAL_REPLICA_ENABLED, $scope, $scopeId);
129+
$this->configWriter->delete(ConfigHelper::LEGACY_USE_VIRTUAL_REPLICA_ENABLED, $scope, $scopeId);
130130
}
131131

132132
protected function simulateFullVirtualReplicas(string $scope, int $scopeId): array

0 commit comments

Comments
 (0)