profile2 extends Entity class and should provide a return value when saving Objects:
Entity Module API - entity_save:
For entity types provided by the CRUD API, SAVED_NEW or SAVED_UPDATED is returned depending on the operation performed. If there is no information how to save the entity, FALSE is returned.
This can be easily provided by 'forwarding' the return value from super class Entity:
public function save() {
// Care about setting created and changed values. But do not automatically
// set a created values for already existing profiles.
if (empty($this->created) && (!empty($this->is_new) || !$this->pid)) {
$this->created = REQUEST_TIME;
}
$this->changed = REQUEST_TIME;
$success = parent::save();
// Update the static cache from profile2_load_by_user().
$cache = &drupal_static('profile2_load_by_user', array());
if (isset($cache[$this->uid])) {
$cache[$this->uid][$this->type] = $this->pid;
}
return $success;
}
Comments
Comment #2
joachim commentedLooks good, but needs spaces either side of the =.
Comment #3
stelli commentedFixed missing spaces
Comment #4
joachim commentedThanks!
Comment #6
stelli commentedPatch converted to unix-style line endings.
Comment #7
stelli commentedFixed paths and filename, applicable by:
patch -p1 < profile2_save_return_value.patch
Comment #11
spleshkaThanks for the patch & review guys. I've tested it myself and commited to 7.x-1.x.