We have very strange errors occasionally popping up in our php logs: Trying to get property of non-object.
This exact error seems to be caused by the access to the member $shortName
in the following if statement:
class MyLocaleWrapper {
…
protected static $system = NULL;
public static function getSystemLocale() {
if (self::$system === NULL) {
self::$system = new self();
self::$system->rfcName = SYSTEM_LOCALE_RFCNAME;
self::$system->shortName = strtolower(Locale::getRegion($rfcName));
if (self::$system->shortName == '') {
self::$system->shortName = strtolower($rfcName);
}
…
if I dump self::$system
into a log file, I see that it is NULL
- right after being constructed with the keyword new
.
The most interesting part is that this file is included in each and every request to our page, so it gets executed ~ 10 times per second. But occasionally it just fails without anyone touching the code (or even the server).
Has anyone else ever experienced such behavior in PHP?