Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(migration): allow migration to run with invalid scopes present #834

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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