Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I noticed that the save() method of EntityDrupalWrapper stores the value returned from entity_save() but does nothing, instead it returns $this. I am unsure whether this was a deliberate decision or not.
However it would be useful if the method returned the return value of entity_save() in order to detect success/failure of the operation (and for that matter, whether it was a create or update operation).
Comments
Comment #1
tnightingale CreditAttribution: tnightingale commentedUpdating with a clearer title.
Comment #2
fagoYes, it has been chose to return $this in order to allow chained usage. Just check whether the entity is new before calling save(), if you need to know whether it is an insert or an update. In case of failures the wrappers always throw exceptions.
I've improved the docs to clarify the exception point.