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 — Construye un nuevo ObjectId
id (string)Una cadena hexadecimal de 24 caracteres. Si no se proporciona, la extensión generará un ObjectId.
id no es una cadena hexadecimal de 24 caracteres.Ejemplo #1 Ejemplo con MongoDB\BSON\ObjectId::__construct()
<?php
var_dump(new MongoDB\BSON\ObjectId());
var_dump(new MongoDB\BSON\ObjectId('000000000000000000000001'));
?>Resultado del ejemplo anterior es similar a:
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.