Hi Frode,

A note on vote B, after reading ext/intl and running ext-scope 0.6.1.

Locale::setDefault() is ini_set('intl.default_locale') today, and
INTL_G(default_locale) is a char* into the ini entry's string.

1. The RFC keeps ini_set('intl.default_locale') request-wide while
   setDefault() follows the scope, so setDefault() has to stop writing
   the ini entry. In ext-scope, ini_set() of date.timezone in a scope
   changes the request, and of intl.default_locale only that scope.

2. A plain swap of INTL_G(default_locale) in core would leave a
   dangling pointer: zend_alter_ini_entry_ex() frees the previous
   string on the next change.

3. If scopes start empty, as in your last message, the locale is not
   neutral. ext/intl falls back to ICU's default, taken from the
   process environment. In ext-scope a new scope got en_US_POSIX, the
   request en_US.

I tried a fix for 1 and 2: setDefault() keeps its own locale string,
which ini_set() does not touch and core can swap per scope. It is
about 40 lines, and with ext-scope swapping through it the locale
behaves as the RFC describes, clean under ASan. As with
date_default_timezone_set(), setDefault() then wins over a later
ini_set() or ini_restore(), and ini_get() no longer shows it. I can
open it as a PR when it helps.

ICU's defaults need no change: ext/intl never sets them.

Regards,
Chris Abner Herrera Navarro

Reply via email to