note 112598 added to class.mongoid

From: Date: Wed, 03 Jul 2013 07:29:45 +0000
Subject: note 112598 added to class.mongoid
Groups: php.notes 
Request: Send a blank email to php-notes+get-195441@lists.php.net to get a copy of this message
Due to Recent changes. * [PHP-554] - MongoId should not get constructed when passing in an invalid ID. Constructor will throw an exception when passing invalid ID. <?php $_id = new MongoId(); //Generates new ID $_id = new MongoId(null); //Generates new ID $_id = new MongoId("invalid id"); //throws MongoException ?> <?php //Revert to old behaviour $_id = "invalid id"; try { $_id = new MongoId($_id); } catch (MongoException $ex) { $_id = new MongoId(); } ?> <?php //Nifty hack class SafeMongoId extends MongoId { public function __construct($id=null) { try { parent::__construct($id); } catch (MongoException $ex) { parent::__construct(null); } } } ?> ---- Server IP: 69.147.83.199 Probable Submitter: 91.226.179.90 ---- Manual Page -- http://php.net/manual/en/class.mongoid.php Edit -- https://master.php.net/note/edit/112598 Del: integrated -- https://master.php.net/note/delete/112598/integrated Del: useless -- https://master.php.net/note/delete/112598/useless Del: bad code -- https://master.php.net/note/delete/112598/bad+code Del: spam -- https://master.php.net/note/delete/112598/spam Del: non-english -- https://master.php.net/note/delete/112598/non-english Del: in docs -- https://master.php.net/note/delete/112598/in+docs Del: other reasons-- https://master.php.net/note/delete/112598 Reject -- https://master.php.net/note/reject/112598 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#195441) next »