Hi Chris,

Thank you for reading ext/intl this closely, and for testing against 
ext-scope.

You found a real inconsistency. In ext-scope 0.6.1, 
ini_set('date.timezone') inside a scope changed the timezone of every 
scope that had not set its own, while ini_set('intl.default_locale') 
stayed in the scope. The rule I want is simpler: for the state a scope 
manages, nothing done in another scope affects it. So both ini entries 
now follow the scope: ini_set(), ini_restore() and ini_get() of 
date.timezone and intl.default_locale act on the current scope only, and 
a new scope starts with the values the request started with. Inside a 
scope they behave as in a request, so date_default_timezone_set() still 
wins over the ini. This is on ext-scope main 
(https://github.com/fiber-interop/ext-scope/commit/5f0e93e) and in the 
polyfill, and will be in the next release. Other ini entries stay 
request-wide.

On the dangling pointer: agreed, for a plain swap of 
INTL_G(default_locale) in core. ext-scope does not swap it. It changes 
the locale through zend_alter_ini_entry(), as Locale::setDefault() does, 
and holds its own reference to each scope's value, so freeing the 
previous ini string leaves nothing dangling. It runs clean under 
valgrind.

On the starting locale: I could not reproduce en_US_POSIX in a new scope 
next to en_US in the request. With intl.default_locale unset, a new 
scope gets the locale the request had at startup, which is ICU's default 
from the process environment: en_US with LANG=en_US.UTF-8, en_US_POSIX 
with LANG=C. That is the same locale a fresh request gets, and I think 
that is the right meaning of a clean scope. If the request had called 
Locale::setDefault('en_US') before creating the scope, the new scope 
would still start with the startup value; was that the case?

Separating Locale::setDefault() from the ini entry is a change to 
ext/intl that stands on its own: with it, setDefault() and ini_set() 
relate the way date_default_timezone_set() and date.timezone already do. 
I would welcome it as a PR, but whether it goes in is for the intl 
maintainers and reviewers to decide, not me. If it lands, ext-scope will 
swap the locale through it.

Regards,
Frode

Reply via email to