Revolution: PHP7 and not utf8 capable system locale

Created on 21 Jul 2016  Â·  8Comments  Â·  Source: modxcms/revolution

Summary

As @kwazaro mentioned in #13002 there is an issue on some shared hosts that makes the manager unusable if the locale setting is not containing an utf8 capable locale.

Step to reproduce

It can't be reproduced here, but he said, that the system works fine on PHP7, but only if "locale" system setting is set to i.e. "en_GB.utf8". If he leaves locale parameter empty the Package Manager doesn't work, there are empty values in reports etc.

Observed behavior

Some parts of the manager don't work, i.e. the Package Manager because of a broken JSON.

Expected behavior

They should not break, if the MODX locale system setting is empty.

Environment

PHP7 on a russian shared host (as far as I know).

bug area-core

Most helpful comment

You even could create a MODX system setting setlocale and fill it with 0. Maybe a setmgrlocale system setting could be created. It would supercede the setlocale setting.

All 8 comments

Yeah, this issue is pretty critical. Weird behavior too.

This error is about setLocale() php function behavior under server environment such as windows 7 as example.
It is also affects not only php7, here is my config Windows 7 Professional Edition Service Pack 1 Apache/2.4.17 (Win32) PHP/5.6.15
Here is some output from my config :

$this->getOption('locale')
"ru_RU.UTF8"

setlocale(LC_ALL, "ru_RU.UTF8")
false

setlocale(LC_ALL, "0")
"Russian_Russia.1251"

strftime('%b %d %Y', 1471864827)
"��� 22 2016"

Here is the root of problem, that causes incorrect symbols output in locale-dependent functions like strftime()
https://github.com/modxcms/revolution/blob/2.x/core/model/modx/modx.class.php#L2374

An approach to solve this would be:

  • Check if the current setting uses a utf8-capable locale.
  • If not run some translit before the array is JSON encoded.

I found temporary solution for this, while we waiting fo fix.
Edit 2 start files
In manager/index.php:
change
$modx->initialize('mgr');
to
$modx->initialize('mgr', ['setlocale'=>false]);

And in connectors/index.php:
$modx->initialize($ctx);
to
$modx->initialize($ctx, ['setlocale' => false]);

You even could create a MODX system setting setlocale and fill it with 0. Maybe a setmgrlocale system setting could be created. It would supercede the setlocale setting.

Can we close this? The system setting is introduced. As far as MODX goes there is not much more can be done here.

modxbughunt

Ran consecutive updates from 2.2.16 to 2.5.7 and was left with a non-working package management.
Web inspector showed that /connectors/workspace/packages.php wasn't loading.
Finally found this thread and saved the suggested system setting to the dbase.
Voila, package management is back.

I Shouldn't this be closed when it also works after updating?

I agree. Feel free to reopen or comment if you disagree.

@modxbot close

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ruslan-Aleev picture Ruslan-Aleev  Â·  3Comments

alexsoin picture alexsoin  Â·  3Comments

netProphET picture netProphET  Â·  3Comments

sottwell picture sottwell  Â·  3Comments

travisbotello picture travisbotello  Â·  3Comments