Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Invalid
-
Affects Version/s: 1.0.0BETA2
-
Fix Version/s: None
-
Component/s: Persister
-
Labels:None
-
Environment:Debian, PHP 5.3.3-7 Suhosin fcgi
Description
I have two documents:
@Document
class A {
/** @Id */
public $id;
/** @ReferenceOne */
public $b;
}@Document
class B {
/** @Id */
public $id;
}
I have an already persisted instance of B, which A references,
though while persisting A and examining the resulting collection the id of B is missing.
{
_id: '000123',
b: {
$db: 'mydb',
$id: '',
$ref: 'b'
}
}
I debugged the code and found the error occurs in DocumentPersister.php at line 210 in the latest git version as of this posting.
The code is:
$inserts[$oid] = $data;
where $data is:
array(
_id => MongoId(000123),
b => array(
$ref => 'b',
$id => MongoID(123000),
$db => 'mydb'
)
)
and $inserts[$oid] becomes:
array(
$oid = array(
_id => MongoId(000123),
b => array(
$ref => 'b',
$id => MongoID(),
$db => 'mydb'
)
)
)
This assignment makes the MongoID disappear somehow!!?
Can't figure it out, could this be a problem with PHP itself?
The problem occurred since i was dumping the class before it was initialized, not realizing that proxy classes lazy loaded.