php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #63050 Change in behaviour for return value of unsafe writes
Submitted: 2012-09-10 00:11 UTC Modified: 2012-11-29 11:38 UTC
From: adam at hipsnip dot com Assigned: derick (profile)
Status: Closed Package: mongo (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2012-09-10 00:11 UTC] adam at hipsnip dot com
Description:
------------
---
From manual page: http://www.php.net/mongo.writes
---

In version 1.2.x of the driver, when performing a write operation with the "safe 
=> false" (unsafe) flag set, it would return a boolean value.
In 1.3.0 (beta2) it appears that this is no longer the case, as these operations 
have no return value (null).
While this makes sense - since we won't really know if the operation succeeded - 
this will break applications which expect that boolean return value.

Therefore this change in behaviour should be noted on the documentation page for 
mongo write operations.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-29 11:38 UTC] derick@php.net
This seems to be not the case in the 1.3.0 final release. It successfully reports bool(true) for me:

<?php
$m = new MongoClient();
$c = $m->selectDb(dbname())->bug605;
$c->remove();
var_dump( $c->insert( array( 'test' => 'one' ) ) );
var_dump( $c->insert( array( 'test' => 'two' ), array( 'w' => 0 ) ) );
var_dump( $c->insert( array( 'test' => 'two' ), array( 'w' => 1 ) ) );
?>

returns (as expected):

array(4) {
  ["n"]=> 
  int(0)
  ["connectionId"]=>
  int(89)
  ["err"]=>
  NULL
  ["ok"]=>
  float(1)
}
bool(true)
array(4) {
  ["n"]=>
  int(0)
  ["connectionId"]=>
  int(89)
  ["err"]=>
  NULL
  ["ok"]=>
  float(1)
}
 [2012-11-29 11:38 UTC] derick@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: derick
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 04:01:28 2025 UTC