Cms: String method issues in PHP 7.3

Created on 9 May 2019  ·  21Comments  ·  Source: craftcms/cms

The setlocale call in web.php#L26 is causing some issues in PHP 7.3.

This currently appears isolated to PHP-Typography, which is a dependency of the popular Typogrify and Wordsmith plugins.

For further background, please see mundschenk-at/php-typography#109.

I’m guessing this could be impactful more broadly. What’s the reasoning behind the setlocale call?

Most helpful comment

Awesome, thanks @angrybrad!

All 21 comments

https://github.com/craftcms/cms/commit/e29b20a13246540d68fe4d9cca6fb13bd5acbe8d

Looks like it was added back in 2014 to fix a bug where files uploaded with Arabic filenames would get the names stripped in some environments.

I bet it has something to do with the PHP 7.3 multibyte extension improvements: https://www.php.net/manual/en/migration73.new-features.php#migration73.new-features.mbstring

@joshuabaker if you wrap that setlocale call in this, I assume it works as expected?

if (PHP_VERSION_ID < 70300) {
   setlocale(...)
}

@angrybrad Yeah, that works.

L30 is the exact culprit (i.e. en_US.UTF-8).

Thanks, @angrybrad. 🙏

I'm having this issue right now with PHP 7.3. Interestingly enough, when using the minimal example from https://github.com/mundschenk-at/php-typography/issues/109#issuecomment-491010719 it works when removing the en_US.utf8 line (after en_US.UTF-8 has already been removed as per 8bf818a) – but it still doesn't fix the display issues with craft-typogrify when removing this line from bootstrap/web.php. So I'm not sure if I may experience a different issue after all. But I wanted to comment here as this is the most relevant issue.

Update: removing the en_US.utf8 in fact DOES fix the issues with craft-typogrify – I just had to clear the template cache first 😉

So in short, I still have this issue and removing the en_US.utf8 line fixes it.

Having the same issue as @msiemens with craft-typogrify. @angrybrad do you know if this is something that is in the pipeline to get addressed?

@jdsimcoe what version of PHP are you running? does removing en_US.utf8 solve it for you?

For me it's PHP 7.3.11 (that's what my hoster provides). And removing en_US.utf8 solves these issues

@angrybrad I'm on PHP 7.3.9 and commenting out that line also fixes the issue for me.

Awesome, thanks @angrybrad!

@angrybrad This also needs to be fixed in the cms/bootstrap/console.php file.

@angrybrad This seems to be showing up again on Craft 3.4.9 & PHP 7.3.13 ... I blame you, of course 😉

@angrybrad they are/were in place and now strangely today, after absolutely no change, I cannot recreate the issue... Maybe this was weirdly some composer caching issue, no idea.

@angrybrad This is showing up in several projects since upgrading to PHP 7.4.0 (with Craft on the latest release). Removing en_US.utf8 seems not to fix the issue this time.

@studiobruikbaar I'm not able to reproduce. If this is on a public box, could you send some Craft control panel and SSH credentials over to [email protected] so we can look into it?

@angrybrad Thanks a lot. I use Valet locally, so I assume that won't work. Anything else I can share with you? Otherwise no problem to downgrade to PHP 7.3 for now.

@studiobruikbaar hrm... I'll setup Valet and see if I can reproduce there.

I'm having this issue come up again regularly when using the Typogrify plugin.

I am also running Valet. This issue persists when changing between PHP 7.2, 7.3, and 7.4.

Update
I was able to resolve my Tyopgrify plugin issues for now by disabling the following setting in the config file:

// Remove extra space characters
"set_space_collapse" => false,

Perhaps this will provide some additional insight into this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bitboxfw picture bitboxfw  ·  3Comments

RitterKnightCreative picture RitterKnightCreative  ·  3Comments

lukebailey picture lukebailey  ·  3Comments

angrybrad picture angrybrad  ·  3Comments

richhayler picture richhayler  ·  3Comments