Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP: object is NULL right after creation
    primarykey
    data
    text
    <p>We have very strange errors occasionally popping up in our <a href="http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-log" rel="nofollow">php logs</a>: <code>Trying to get property of non-object.</code></p> <p>This exact error seems to be caused by the access to the member <code>$shortName</code> in the following if statement:</p> <pre><code>class MyLocaleWrapper extends SomeOtherClass { … protected static $system = NULL; public static function getSystemLocale() { if (self::$system === NULL) { self::$system = new self(); debug(self::$system); self::$system-&gt;rfcName = SYSTEM_LOCALE_RFCNAME; self::$system-&gt;shortName = strtolower(Locale::getRegion(self::$system-&gt;rfcName)); if (self::$system-&gt;shortName == '') { self::$system-&gt;shortName = strtolower(self::$system-&gt;rfcName); } … # in another file: class SomeOtherClass { … public function __construct() { # Some documentation about features that have been # removed from the constructor, but no real code in here. return NULL; } … # in yet another file: MyLocaleWrapper::getSystemLocale(); </code></pre> <p>if I dump <code>self::$system</code> into a log file, I see that it is <code>NULL</code> - right after being constructed with the keyword <code>new</code>.</p> <p>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).</p> <p>Has anyone else ever experienced such behavior in PHP?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload