magento / data-migration-tool

Magento Data Migration Tool
https://devdocs.magento.com/guides/v2.3/migration/bk-migration-guide.html
Open Software License 3.0
334 stars 200 forks source link

Deprecated Functionality: preg_replace(): #924

Open ioweb-gr opened 4 days ago

ioweb-gr commented 4 days ago

Preconditions

  1. 1.9.4.5
  2. 2.4.7

Steps to reproduce

  1. Run the data migration step
  2. See the error
 Deprecated Functionality: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /httpdocs/vendor/magento/data-migration-tool/src/Migration/Handler/TruncateSuffix.ph
  p on line 93

This is a php version incompatibility that needs to be fixed

Expected result

  1. No warning is thrown

Actual result

  1. Warning is thrown

Additional notes

image

Fixed with

Index: vendor/magento/data-migration-tool/src/Migration/Handler/TruncateSuffix.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/vendor/magento/data-migration-tool/src/Migration/Handler/TruncateSuffix.php b/vendor/magento/data-migration-tool/src/Migration/Handler/TruncateSuffix.php
--- a/vendor/magento/data-migration-tool/src/Migration/Handler/TruncateSuffix.php   
+++ b/vendor/magento/data-migration-tool/src/Migration/Handler/TruncateSuffix.php   (date 1718293775929)
@@ -90,7 +90,7 @@
         if (in_array($recordToHandle->getValue('attribute_id'), $attributeIds)) {
             $suffix = '~' . preg_quote($this->getSuffix()) . '$~';
             $value = $recordToHandle->getValue($this->field);
-            $value = preg_replace($suffix, '', $value);
+            $value = preg_replace($suffix, '', (string)$value);
             $recordToHandle->setValue($this->field, $value);
         }
     }
m2-assistant[bot] commented 4 days ago

Hi @ioweb-gr. Thank you for your report. To speed up processing of this issue, make sure that you provided sufficient information. Add a comment to assign the issue: @magento I am working on this


Join Magento Community Engineering Slack and ask your questions in #github channel.