Closed (won't fix)
Project:
Entity API
Version:
7.x-1.x-dev
Component:
Entity CRUD API - main
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
3 Dec 2010 at 15:30 UTC
Updated:
3 Dec 2010 at 16:16 UTC
When i try to save an entity, the save() method return NULL.
I've seen that the properties of the Entity class are dynamically defined in entity.db.inc l.40:
// Set initial values.
foreach ($values as $key => $value) {
$this->$key = $value;
}
But drupal_write_record() use the function property_exists() which check each property of the entity in includes/common.inc l.6684:
if (!property_exists($object, $field)) {
// Skip fields that are not provided, default values are already known
// by the database.
continue;
}
All the properties of my entity are skipped because they are dynamically defined.
On php.net you can read that note about property_exists:
"The property_exists() function cannot detect properties that are magically accessible using the __get magic method."
Comments
Comment #1
fagoYep, the entity API doesn't support magic properties, just by the fact drupal_write_record() doesn't support them. So not really a problem of the entity API, but of that function. However, I'd not suggest using magic properties for something like entity properties anyway.