You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an object I am creating for storage in Mongo using Model::create(array()); I store a temporary property on the object for use in an override method of save, and then right before I call parent::save($entity) I unset the property (unset($entity->property) as its not needed anymore. The property is not unset, and when parent::save is called, the property is saved. I can, at this point, say $entity->property = NULL and it updates the value of the property before save, so I'm not sure why unsetting it would still keep a reference. According to: http://li3.me/docs/lithium/data/entity/Document::__unset() I believe this should work. Can anyone cast any light? Am I doing something wrong?
The text was updated successfully, but these errors were encountered:
unset() on a Document will indicate to remove a field mirroring behavior/name of mongo's $unset operator. Field removal/rename is not yet implemented in the Exporter.
Even if those capabilities were there: when calling unset() on fields previously added in the same session you'd expect different behavior, than actually causing the field to be removed in the database
All this does not help solve the issue you have now, but explains where it's coming from. Please use whitelists as detailed above, to prevent temporary Document fields to leak into Mongo or use a locked Mongo Schema.
Technical note: Going forward Document/Entity should be refactored to use an array of sequential "ops" (i.e. `[['add' => 'foo'], ['remove' => 'foo]]) and resolve those when building the query (practically a FSM) or use a simple diffing algorithm. Currently these informations is spread out across a handful of properties (there should be one source of truth).
I have an object I am creating for storage in Mongo using Model::create(array()); I store a temporary property on the object for use in an override method of save, and then right before I call parent::save($entity) I unset the property (unset($entity->property) as its not needed anymore. The property is not unset, and when parent::save is called, the property is saved. I can, at this point, say $entity->property = NULL and it updates the value of the property before save, so I'm not sure why unsetting it would still keep a reference. According to: http://li3.me/docs/lithium/data/entity/Document::__unset() I believe this should work. Can anyone cast any light? Am I doing something wrong?
The text was updated successfully, but these errors were encountered: