Skip Navigation
Expand
Post upgrade, CPMs error with "Trying to get property of non-object"
Answer ID 9256   |   Last Review Date 12/24/2018

Why is my PHP code showing an error "Trying to get property of non-object", post-upgrade to November 2016?

Environment

Oracle Cloud Service November 2016 release

Resolution

Check objects using if(isset(...)) before instantiating them.

Sample code:

Replace  $sample = $object->Contact;  

with

if(isset($object)) {

$sample = $object->Contact;

}

Cause

 Along with the upgrade to November 2016, there is an upgrade to the PHP version as well.

The new PHP version is stricter than the older ones and requires objects to be checked before they are referenced into the code.