Skip to content

Commit

Permalink
fix(migration): allow migration to run with invalid scopes present (#834
Browse files Browse the repository at this point in the history
)
  • Loading branch information
joerivanveen authored Apr 2, 2024
1 parent 2ee26ef commit 6eb73f6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Setup/UpgradeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -741,11 +741,13 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface

$getConfigRow = static function (string $path, string $scope, int $scopeId) use ($connection, $table) {
if (! in_array($scope, ['default', 'websites', 'stores'], true)) {
throw new \InvalidArgumentException("Invalid scope $scope");
echo "\nIgnored invalid scope $scope";
return null;
}

if (! preg_match('/^[a-z0-9_\/]+$/i', $path)) {
throw new \InvalidArgumentException("Invalid path $path");
echo "\nIgnored invalid path $path";
return null;
}

$sql = "SELECT config_id, path, value FROM $table WHERE `path` = \"$path\" AND `scope` = \"$scope\" AND `scope_id` = $scopeId";
Expand All @@ -764,6 +766,15 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
$deliveryDaysWindow = 0;

foreach ($scopes as $scope => $scopeId) {
if ('default' === $scope) {
$scopeId = 0;
}

if (! in_array($scope, ['default', 'websites', 'stores'], true)) {
echo "\nSkipping invalid scope $scope";
continue;
}

foreach (Data::CARRIERS_XML_PATH_MAP as $carrierName => $carrierPath) {
echo "\nMigrating $carrierName for scope $scope ($scopeId)";
/**
Expand Down

0 comments on commit 6eb73f6

Please sign in to comment.