My script runs a loop that changes the locale (multilingual application). I've noticed that on some random occasion the locale still hasn't changed despite the setlocale() function being executed a step earlier. I had to add wait time for this condition. Interestingly enough, this was the case only with the 'nl_NL.UTF8' locale.
<?php
$this->counter = 0;
$this->locale = 'nl_NL.UTF8';
setlocale(LC_ALL, $this->locale);
$this->counter++;
if ($this->locale !== setlocale(LC_CTYPE, 0)) { if ($this->counter > 10) {
return;
}
sleep(1);
}
?>