Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Warning showed when property is null
  • FuelPHP 1.8.1
    PHP 7.2.7

    Controller:
    class Controller_Company extends \common\Controller_Base {
    public function action_index()
        {
            (\Auth\Auth::has_access('company.update') === false) and $this->restricted_page();

    $company = Model_Company::query()->where('master_account_id', $this->current_user->id)->get_one();
    $company->logo;
    ...
    }
    }

    The above code fails if the property "logo" is NULL .

    Warning:

    ErrorException [ Warning ]: get_class() expects parameter 1 to be object, null given

    COREPATH/classes/security.php @ line 241

    line 241

    elseif ($value instanceof \Iterator or get_class($value) == 'stdClass')

    The fix I made:

    elseif(is_null($value))

    {

       return $value;

    }

    elseif ($value instanceof \Iterator or get_class($value) == 'stdClass')


Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion