PrestaShop / PrestaShop

PrestaShop is the universal open-source software platform to build your e-commerce solution.
https://www.prestashop-project.org/
Other
8.15k stars 4.8k forks source link

PHP function str2url giving another results than JS function str2url (mbstring is enabled) #33819

Open ShaiMagal opened 1 year ago

ShaiMagal commented 1 year ago

Prerequisites

Describe the bug and add attachments

Expected behavior

PHP function must give same results like JS function.

Steps to reproduce

1) create product with name "hülle" 2) you will get seo url like "huelle" 3) now try get seo url with PHP function: Tools::str2url("hülle") 4) you will get another result "hulle"

PrestaShop version(s) where the bug happened

8.0.3

PHP version(s) where the bug happened

8.1

If your bug is related to a module, specify its name and its version

No response

Your company or customer's name goes here (if applicable).

No response

kpodemski commented 1 year ago

Hello @ShaiMagal

Could you take a look at this PR and see if it helps to unify the behavior?

ShaiMagal commented 1 year ago

Hello @ShaiMagal

Could you take a look at this PR and see if it helps to unify the behavior?

Hi, @kpodemski PS 8.x has another code for function "replaceAccentedChars".

This PR 26160 is for PS 1.7, there is different function "replaceAccentedChars" than PS 8.x

PS 8.x code looks like (different from PR provided, it's PR for PS 1.7, not 8.x):

    public static function replaceAccentedChars($str)
    {
        static $transliterator;

        if (!$transliterator) {
            $transliterator = Transliterator::create('Any-Latin; Latin-ASCII');
        }

        return $transliterator->transliterate($str);
    }
valentin-anamorphik commented 1 year ago

Hi,

I have a problem with this new function on PS 8.x. Some special characters are no longer removed from the "link_rewrite" property.

$transliterator = Transliterator::create('Any-Latin; Latin-ASCII');
echo $transliterator->transliterate("Copyright ®");
// return => "Copyright (R)"

And so my URL looks like this: mysite.com/category/123456-copyrightR.html With the letter R in capital.

On PS 7.x, it was mysite.com/category/123456-copyright.html

@ShaiMagal @kpodemski Did you find a solution ?

ShaiMagal commented 11 months ago

@valentin-anamorphik Unfortunately I am not familiar with this... So I opened only this issue, not PR... :/ I don't know how to fix correctly without BC. Both functions from PHP and JS should give same results...

Btw, I think, this is minor problem. There is more than 2000 issues opened, so very complicated with this numbers to prioritize this issue...