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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: adam at hipsnip dot com
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 17:01:30 2024 UTC