data-migration-tool icon indicating copy to clipboard operation
data-migration-tool copied to clipboard

Deprecated Functionality: preg_replace()

Open Andreabont opened this issue 3 years ago • 5 comments

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

[2022-08-04T08:44:12.308463+00:00][INFO][mode: data][stage: data migration][step: Map Step]: started 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

Andreabont avatar Aug 04 '22 08:08 Andreabont

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


m2-assistant[bot] avatar Aug 04 '22 08:08 m2-assistant[bot]

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);
         }
     }

mlaurense avatar Nov 21 '22 16:11 mlaurense

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

VrumVrum avatar Jun 29 '23 08:06 VrumVrum

@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)

mlaurense avatar Jun 29 '23 13:06 mlaurense