Error message - Trying to get property of non-object

Error message - Trying to get property of non-object

by JC Dodo -
Number of replies: 0

Hi,

I have custom Moodle plugin which is working OK on PHP 5.4. After upgrading to PHP 5.6, it started to work improperly.

I got this error message from the log file.

Notice: Trying to get property of non-object in /path/to/moodle/local/customplugin/filename.php on line 21

Looking into that line 21, it draws my attention that the root cause of problem for non-object is on line 20 which is:

$grade =  json_decode($this->get_custom_data_as_string());

So what happen is that when: 

1. I do manual calculation of the grade result to competency, the output of

var_dump($grade); 
is int(0).

2. I do automatic calculation of the grade result to competency, the output of

var_dump($grade);
is an object which having a list of tables.


Do you have any idea why is this? How to correct on this case?

By the way, I am using Moodle version 3.2.

Thanks!