php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64932 new MongoId ('-1'); generate exception
Submitted: 2013-05-27 21:16 UTC Modified: 2013-07-14 19:44 UTC
Votes:15
Avg. Score:4.9 ± 0.5
Reproduced:12 of 12 (100.0%)
Same Version:8 (66.7%)
Same OS:6 (50.0%)
From: al at webkpd dot com Assigned:
Status: Not a bug Package: mongo (PECL)
PHP Version: 5.4.15 OS: Linux Ubunty x86-64
Private report: No CVE-ID: None
 [2013-05-27 21:16 UTC] al at webkpd dot com
Description:
------------
http://php.net/manual/en/class.mongoid.php

def: public __construct ([ string $id = NULL ] )

any string!

why new MongoId ('-1'); // generate exception?
but new MongoId ('5197647495931abe07000000');

pecl version of mongo 1.4.0. on 1.3.X branch it was ok

Test script:
---------------
<?
$id = MongoId ('-1');

Expected result:
----------------
get_type($id ) => MongoId instance

Actual result:
--------------
exception:
object(MongoException)[41]
  protected 'message' => string 'Invalid object ID' (length=17)
  private 'string' (Exception) => string '' (length=0)
  protected 'code' => int 19
  protected 'file' => ...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-14 19:44 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2013-07-14 19:44 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Since driver version 1.4 we actually verify the format so that we don't end up sending incorrect data to the server.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 08:02:42 2024 UTC