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() #899

Open Andreabont opened 1 year ago

Andreabont commented 1 year ago

Preconditions

  1. From Magento 1.9.0.1
  2. To Magento 2.4.4
  3. PHP 8.1

Steps to reproduce

  1. bin/magento migrate:data vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.0.1/config.xml.dist -a

Expected result

  1. Successful migration

Actual result

0% [>---------------------------] Remaining Time: < 1 sec In ErrorHandler.php line 61:

Deprecated Functionality: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in /var/www/html/vendor/magento/data-migration-tool/src/Migration/Handler/TruncateSuffix.
php on line 93

Additional notes

m2-assistant[bot] commented 1 year ago

Hi @Andreabont. 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


mlaurense commented 1 year ago

Unbelievable that this is still an issue. You can apply this patch to fix it:

--- src/Migration/Handler/TruncateSuffix.php    2022-04-11 15:42:50.000000000 +0000
+++ src/Migration/Handler/TruncateSuffix.php    2022-11-21 16:30:02.926243596 +0000
@@ -90,7 +90,8 @@
         if (in_array($recordToHandle->getValue('attribute_id'), $attributeIds)) {
             $suffix = '~' . preg_quote($this->getSuffix()) . '$~';
             $value = $recordToHandle->getValue($this->field);
-            $value = preg_replace($suffix, '', $value);
+            if ($value !== null)
+                $value = preg_replace($suffix, '', $value);
             $recordToHandle->setValue($this->field, $value);
         }
     }
VrumVrum commented 12 months ago

mlaurense, Already tried to apply your patch, but its the same issue for 2.4.5 version. Any thoughts? This is not yet fixed...

Thank you

mlaurense commented 12 months ago

@VrumVrum You mean it is STILL not fixed... it appears the file is the same in 2.4.5 tag, so you should be able to apply the patch successfully. Check if your vendor/magento/data-migration-tool/src/Migration/Handler/TruncateSuffix.php is changed; line 93 should contain the if ($value !== null)