ActiveQuery::one Returning NULL When Row Exists

Last night out of the blue our site stopped functioning correctly. I traced the issue to the following function in ActiveQuery:




    public function one($db = null)

    {

        $row = parent::one($db);

        if ($row !== false) {

            $models = $this->populate([$row]);

            return reset($models) ?: null;

        } else {

            return null;

        }

    }



To confirm what is being returned from this function, if I add the following line before the first return statement I get NULL:




   var_dump(reset($models) ?: null);



However, if I add the following line before the first return statement I get the anticipated row:




   var_dump(reset($models));



The code works on my local machine (php 5.4.3) and used to work on the hosting server (php 5.4.41). I am in the process of seeing if they upgraded PHP overnight.

Any idea what is causing this syntax to fail on our hosting server?

I just found in my cPanel where I could switch the PHP version, so I changed it to 5.5. It now works fine. Why it work on version 5.4 on my computer but has to be 5.5 on the server, I don’t know.