magento / magento/data-migration-tool
Deprecated Functionality: preg_replace():
- Dominant language
- PHP
- Stars
- 339
- Forks
- 195
- PR merge metrics
- No merged PRs in 30d
Description
### 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

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);
}
}
```
Contributor guide
Research direction
Start with src/Migration/Handler/TruncateSuffix.php around line 93 and reproduce the data migration step using the reported Magento versions. Verify how a null value reaches preg_replace(), then confirm the migration completes without the deprecation warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100