Fixed #1051: Bug - Trying to get property of non-object - Integrity constraint violation: 1062 Duplicate entry