From 148cd1101520ef21a5d70dc35812cca911692899 Mon Sep 17 00:00:00 2001 From: Viktor Rad Date: Thu, 12 Jan 2023 21:25:52 -0600 Subject: [PATCH] ACP2E-1531: Data Migration Tool 2.4.5 with PHP 8.1 compatibility issues --- composer.json | 2 +- src/Migration/Handler/SetValue.php | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 1eb83c148..1b284c75e 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Migration Tool", "version": "2.4.5", "require": { - "symfony/console": "~4.4.0", + "symfony/console": "^5.4", "magento/framework": "*", "monolog/monolog": "^2.3" }, diff --git a/src/Migration/Handler/SetValue.php b/src/Migration/Handler/SetValue.php index c1aad8746..992b6ff14 100644 --- a/src/Migration/Handler/SetValue.php +++ b/src/Migration/Handler/SetValue.php @@ -32,17 +32,20 @@ public function handle(Record $recordToHandle, Record $oppositeRecord) { $this->validate($recordToHandle); $valueStored = $recordToHandle->getValue($this->field); - $operator = substr($this->value, 0, 1); - $value = substr($this->value, 1); - switch ($operator) { - case '+': - $value = $valueStored + $value; - break; - case '-'; - $value = $valueStored - $value; - break; - default: - $value = $this->value; + $value = $this->value; + if (is_string($value)) { + $operator = substr($value, 0, 1); + $value = substr($value, 1); + switch ($operator) { + case '+': + $value = $valueStored + $value; + break; + case '-'; + $value = $valueStored - $value; + break; + default: + $value = $this->value; + } } $recordToHandle->setValue($this->field, $value); }