1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
--TEST--
Test for PHP-522: Setting per-insert options. (streams)
--SKIPIF--
<?php if (!MONGO_STREAMS) { echo "skip This test requires streams support"; } ?>
<?php $needs = "2.5.5"; ?>
<?php require_once "tests/utils/replicaset.inc";?>
--FILE--
<?php
require_once "tests/utils/server.inc";
require_once "tests/utils/stream-notifications.inc";
function dump_writeOptions(MongoNotifications $mn) {
$meta = $mn->getLastInsertMeta();
var_dump($meta['write_options']);
}
$mn = new MongoNotifications;
$ctx = stream_context_create(
array(),
array(
"notification" => array($mn, "update")
)
);
$rs = MongoShellServer::getReplicasetInfo();
$m = new MongoClient($rs['dsn'], array('replicaSet' => $rs['rsname']), array("context" => $ctx));
$c = $m->selectCollection( dbname(), "php-522_error_26" );
try {
$retval = $c->insert( array( 'test' => 1 ), array( 'fsync' => "1", 'safe' => 1, 'w' => 4, 'socketTimeoutMS' => "1" ) );
var_dump($retval["ok"]);
} catch ( Exception $e ) {
echo $e->getMessage(), "\n";
}
dump_writeOptions($mn);
echo "-----\n";
try {
$retval = $c->insert( array( 'test' => 1 ), array( 'fsync' => "1", 'safe' => 1, 'w' => 4, 'socketTimeoutMS' => "1foo" ) );
var_dump($retval["ok"]);
} catch ( Exception $e ) {
echo $e->getMessage(), "\n";
}
dump_writeOptions($mn);
echo "-----\n";
try {
$c->w = 2;
$retval = $c->insert( array( 'test' => 1 ), array( 'fsync' => false, 'safe' => 1, 'socketTimeoutMS' => M_PI * 1000 ) );
var_dump($retval["ok"]);
} catch ( Exception $e ) {
echo $e->getMessage(), "\n";
}
dump_writeOptions($mn);
echo "-----\n";
try {
$c->w = 2;
$retval = $c->insert( array( 'test' => 1 ), array( 'fsync' => "yesplease", 'safe' => 5, 'socketTimeoutMS' => M_PI * 1000 ) );
var_dump($retval["ok"]);
} catch ( Exception $e ) {
echo $e->getMessage(), "\n";
}
dump_writeOptions($mn);
echo "-----\n";
try {
$c->w = 2;
$c->wtimeout = 4500;
$retval = $c->insert( array( 'test' => 1 ), array( 'fsync' => false, 'safe' => "allDCs", 'socketTimeoutMS' => M_PI * 1000 ) );
var_dump($retval["ok"]);
} catch ( Exception $e ) {
echo $e->getMessage(), "\n";
}
dump_writeOptions($mn);
echo "-----\n";
?>
--EXPECTF--
%s: MongoCollection::insert(): The 'safe' option is deprecated, please use 'w' instead in %s on line %d
%s:%d: Read timed out after reading 0 bytes, waited for 0.001000 seconds
array(1) {
["writeConcern"]=>
array(3) {
["fsync"]=>
bool(true)
["j"]=>
bool(false)
["w"]=>
int(4)
}
}
-----
%s: MongoCollection::insert(): The 'safe' option is deprecated, please use 'w' instead in %s on line %d
%s:%d: Read timed out after reading 0 bytes, waited for 0.001000 seconds
array(1) {
["writeConcern"]=>
array(3) {
["fsync"]=>
bool(true)
["j"]=>
bool(false)
["w"]=>
int(4)
}
}
-----
%s: MongoCollection::insert(): The 'safe' option is deprecated, please use 'w' instead in %s on line %d
%s: MongoCollection::insert(): Using w=2 rather than w=1 as suggested by deprecated 'safe' value in %s on line %d
float(1)
array(1) {
["writeConcern"]=>
array(3) {
["fsync"]=>
bool(false)
["j"]=>
bool(false)
["w"]=>
int(2)
}
}
-----
%s: MongoCollection::insert(): The 'safe' option is deprecated, please use 'w' instead in %s on line %d
%s:%d: Read timed out after reading 0 bytes, waited for 3.141000 seconds
array(1) {
["writeConcern"]=>
array(3) {
["fsync"]=>
bool(true)
["j"]=>
bool(false)
["w"]=>
int(5)
}
}
-----
%s: MongoCollection::insert(): The 'safe' option is deprecated, please use 'w' instead in %s on line %d
%s:%d:%sunrecognized getLastError mode: allDCs
array(1) {
["writeConcern"]=>
array(4) {
["fsync"]=>
bool(false)
["j"]=>
bool(false)
["wtimeout"]=>
int(4500)
["w"]=>
string(6) "allDCs"
}
}
-----
|