If you pass NULL to the __construct() method, it wont throw exceptions, nor errors, but prematurely ends the PHP processing (so it produced an 502 response over nginx), not like the legacy MongoId class.(mongodb >=1.0.0)
MongoDB\BSON\ObjectId::__construct — Construit un nouvel ObjectId
id (string)Une chaîne héxadécimale de 24 caractères. Si elle n'est pas fournie, l'extension génèrera un ObjectId.
id n'est pas une chaîne héxadécimale de 24 caractères.Exemple #1 Exemple avec MongoDB\BSON\ObjectId::__construct()
<?php
var_dump(new MongoDB\BSON\ObjectId());
var_dump(new MongoDB\BSON\ObjectId('000000000000000000000001'));
?>Résultat de l'exemple ci-dessus est similaire à :
object(MongoDB\BSON\ObjectId)#1 (1) {
["oid"]=>
string(24) "56732d3dda14d81214634921"
}
object(MongoDB\BSON\ObjectId)#1 (1) {
["oid"]=>
string(24) "000000000000000000000001"
}
If you pass NULL to the __construct() method, it wont throw exceptions, nor errors, but prematurely ends the PHP processing (so it produced an 502 response over nginx), not like the legacy MongoId class.