Symptoms

The following error is thrown when trying to provision resource:

Internal Server Error: Trying to get property of non-object at /usr/share/aps/php/aps/2/aps.php:584 

Cause

It is an attempt to get a property of an object but the object is empty. For instance the error might be displayed when user wants to get subscription ID by creating a relation to it:

"relations": {
    "subscription": {
        "type": "http://aps-standard.org/types/core/subscription/1.0",
        "collection": false
    }
}

and tries to get the id in provision() method:

$subscription_id = $this->subscription->subscriptionId;

But since there is no required: true attribute in resource schema the link was not created automatically so $this->subscription is empty and trying to get 'subscriptionId' property of this object would result in "Trying to get property of non-object" error.

Resolution

There is no general solution for this error, it is needed to add troubleshooting code and verify object existence before trying to use it.

Internal content

Link on internal Article