H3XED
Programming   Browse Topics

Magento 2 M2E Pro Shipping Policy Bug Unknown Modifier H

Posted Jul 19, 2017 by Nick Vogt
When attempting to edit or create an eBay Shipping Policy in M2E Pro for Magento 2, you may come across an error like this:

{"error": "Warning: preg_replace(): Unknown modifier 'H' in \/app\/code\/Ess\/M2ePro\/Block\/Adminhtml\/Ebay\/Template\/Shipping\/Edit\/Form\/Data.php on line 1733"}

This happens because the method modifyNonUniqueShippingServicesTitles doesn't properly escape a string before running it through a preg_replace, causing the regular expression to end early. That method is located in this file:

/app/code/Ess/M2ePro/Block/Adminhtml/Ebay/Template/Shipping/Edit/Form/Data.php
The part of the method that is failing is at this line:

$uniqPart = preg_replace('/\w*'.str_replace(' ', '', $title).'/i', '', $ebayId);
To resolve it, add this line of code prior to that code:

// Escapes any '/' in title so preg_replace doesn't fail
$title = str_replace('/', '\/', $title);

It should now look like this:

// Escapes any '/' in title so preg_replace doesn't fail
$title = str_replace('/', '\/', $title);
$uniqPart = preg_replace('/\w*'.str_replace(' ', '', $title).'/i', '', $ebayId);

I have submitted this bug to M2E Pro in hopes they'll fix it in the next update.
Share This Post
Facebook Twitter

Comments


Share This Post
Facebook Twitter
H3XED © Nick Vogt   RSS   Privacy Policy   Facebook   Twitter   Google+