This issue May cause with following scenarios:
Issue: In config file $CFG->dataroot is not setup.
Solution: Create a directory and configure in config file.
Issue: moodledata not writable.
Solution: Check for moodledata directory in config file and make it writable with apache 777 permissions.
Issue: Object is becoming non object.
Solution: Issue is with php 5.3.2 version by upgrading php version we can fix this issue.