Commit 5a6f825a authored by Ondrej Sury's avatar Ondrej Sury

New upstream version 1.2.8

parent dc6eb3f7
--TEST--
MongoDB\Driver\Manager::executeBulkWrite() insert write error
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
$manager = new MongoDB\Driver\Manager(STANDALONE);
$bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(['$foo' => 1]);
try {
$manager->executeBulkWrite(NS, $bulk);
} catch (MongoDB\Driver\Exception\BulkWriteException $e) {
printf("BulkWriteException: %s\n", $e->getMessage());
echo "\n===> WriteResult\n";
printWriteResult($e->getWriteResult());
}
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
BulkWriteException: Document can't have $ prefixed field names: $foo
===> WriteResult
server: %s:%d
insertedCount: 0
matchedCount: 0
modifiedCount: 0
upsertedCount: 0
deletedCount: 0
object(MongoDB\Driver\WriteError)#%d (%d) {
["message"]=>
string(48) "Document can't have $ prefixed field names: $foo"
["code"]=>
int(2)
["index"]=>
int(0)
["info"]=>
NULL
}
writeError[0].message: Document can't have $ prefixed field names: $foo
writeError[0].code: 2
===DONE===
--TEST--
MongoDB\Driver\Manager: Executing Query without assignment still executes
--SKIPIF--
<?php if (defined("HHVM_VERSION_ID")) exit("skip HHVM uses HHVM's logging functionality"); ?>
<?php require __DIR__ . "/../utils/basic-skipif.inc"; CLEANUP(STANDALONE) ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
$manager = new MongoDB\Driver\Manager(STANDALONE);
$bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(array('_id' => 1, 'x' => 1));
$bulk->insert(array('_id' => 2, 'x' => 1));
$manager->executeBulkWrite(NS, $bulk);
ini_set("mongodb.debug", "stdout");
$manager->executeQuery(NS, new MongoDB\Driver\Query(array("x" => 1)));
ini_set("mongodb.debug", "off");
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
%a
[%s] cursor: TRACE > ENTRY: mongoc_cursor_next():%d
%a
[%s] cursor: TRACE > EXIT: mongoc_cursor_destroy():%d
===DONE===
--TEST--
PHPC-487: check_closed stream handler should not report open socket as closed
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; SLOW(); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
$m = new MongoDB\Driver\Manager(STANDALONE);
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$wr = $m->executeBulkWrite(NS, $bulk);
var_dump($wr->getInsertedCount());
sleep(1);
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$wr = $m->executeBulkWrite(NS, $bulk);
var_dump($wr->getInsertedCount());
?>
===DONE===
<?php exit(0); ?>
--EXPECT--
int(1)
int(1)
===DONE===
--TEST--
PHPC-487: Stream handler should report closed socket as closed
--SKIPIF--
<?php require __DIR__ . "/../utils/basic-skipif.inc"; SLOW(); ?>
--FILE--
<?php
require_once __DIR__ . "/../utils/basic.inc";
function mo_delete($id) {
$url = getMOUri() . $id;
$opts = array("http" =>
array(
"method" => "DELETE",
"timeout" => 60,
"header" => "Accept: application/json\r\n" .
"Content-type: application/x-www-form-urlencoded",
"ignore_errors" => true,
),
);
$context = stream_context_create($opts);
$out = file_get_contents($url, false, $context);
}
function mo_post($url, $body) {
global $KILLLIST;
$url = getMOUri() . $url;
$opts = array("http" =>
array(
"method" => "POST",
"timeout" => 60,
"header" => "Accept: application/json\r\n" .
"Content-type: application/x-www-form-urlencoded",
"content" => json_encode($body),
"ignore_errors" => true,
),
);
$context = stream_context_create($opts);
$out = file_get_contents($url, false, $context);
$array = json_decode($out, true);
if ($array && !empty($array["mongodb_uri"])) {
$KILLLIST[] = $array["id"];
return $array["mongodb_uri"];
}
}
$KILLLIST = array();
$dsn = mo_post("/servers", [
'id' => 'serverA',
'name' => 'mongod',
]);
$m = new MongoDB\Driver\Manager($dsn);
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$wr = $m->executeBulkWrite(NS, $bulk);
var_dump($wr->getInsertedCount());
mo_post("/servers/serverA", ['action' => 'stop']);
echo throws(function() use ($m) {
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$wr = $m->executeBulkWrite(NS, $bulk);
var_dump($wr->getInsertedCount());
}, 'MongoDB\Driver\Exception\RuntimeException'), "\n";
mo_post("/servers/serverA", ['action' => 'restart']);
$bulk = new MongoDB\Driver\BulkWrite;
$bulk->insert(['x' => 1]);
$wr = $m->executeBulkWrite(NS, $bulk);
var_dump($wr->getInsertedCount());
foreach($KILLLIST as $id) {
mo_delete("/servers/$id");
}
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
int(1)
OK: Got MongoDB\Driver\Exception\RuntimeException
Failed to send "insert" command with database "phongo": socket error or timeout
int(1)
===DONE===
......@@ -57,25 +57,39 @@ if (PHP_MONGODB != "no") {
* once we support building with Secure Channel. */
ADD_EXTENSION_DEP("mongodb", "openssl", false);
ADD_FLAG("CFLAGS_MONGODB", " /D BSON_COMPILATION /D MONGOC_COMPILATION /D MONGOC_TRACE /I" + configure_module_dirname + " /I" + configure_module_dirname + "/src/libmongoc/src/mongoc" + " /I" + configure_module_dirname + "/src/libbson/src/bson/ /I" + configure_module_dirname + "/src/libbson/src /I" + configure_module_dirname + "/src/contrib");
EXTENSION("mongodb", "php_phongo.c");
ADD_SOURCES(configure_module_dirname + "/", "phongo_compat.c", "mongodb");
var PHP_MONGODB_CFLAGS="\
/D BSON_COMPILATION /D MONGOC_COMPILATION /D MONGOC_TRACE \
/I" + configure_module_dirname + " \
/I" + configure_module_dirname + "/src/BSON \
/I" + configure_module_dirname + "/src/MongoDB \
/I" + configure_module_dirname + "/src/MongoDB/Exception \
/I" + configure_module_dirname + "/src/contrib \
/I" + configure_module_dirname + "/src/libbson/src \
/I" + configure_module_dirname + "/src/libbson/src/bson \
/I" + configure_module_dirname + "/src/libbson/src/yajl \
/I" + configure_module_dirname + "/src/libmongoc/src/mongoc \
";
// Condense whitespace in CFLAGS
PHP_MONGODB_CFLAGS = PHP_MONGODB_CFLAGS.replace(/\s+/g, ' ');
// Generated with: find src/libbson/src/bson -name '*.c' -print0 | cut -sz -d / -f 5- | sort -z | tr '\000' ' '
var PHP_MONGODB_BSON_SOURCES="bcon.c bson-atomic.c bson.c bson-clock.c bson-context.c bson-decimal128.c bson-error.c bson-iso8601.c bson-iter.c bson-json.c bson-keys.c bson-md5.c bson-memory.c bson-oid.c bson-reader.c bson-string.c bson-timegm.c bson-utf8.c bson-value.c bson-version-functions.c bson-writer.c";
// Generated with: find src/libbson/src/yajl -name '*.c' -print0 | cut -sz -d / -f 5- | sort -z | tr '\000' ' '
var PHP_MONGODB_YAJL_SOURCES="yajl_alloc.c yajl_buf.c yajl.c yajl_encode.c yajl_gen.c yajl_lex.c yajl_parser.c yajl_tree.c yajl_version.c";
// Generated with: find src/libmongoc/src/mongoc -name '*.c' -print0 | cut -sz -d / -f 4- | sort -z | tr '\000' ' '
var PHP_MONGODB_MONGOC_SOURCES="mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-b64.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-client.c mongoc-client-pool.c mongoc-cluster.c mongoc-collection.c mongoc-counters.c mongoc-crypto.c mongoc-crypto-cng.c mongoc-crypto-common-crypto.c mongoc-crypto-openssl.c mongoc-cursor-array.c mongoc-cursor.c mongoc-cursor-cursorid.c mongoc-cursor-transform.c mongoc-database.c mongoc-find-and-modify.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-list.c mongoc-gridfs-file-page.c mongoc-handshake.c mongoc-host-list.c mongoc-index.c mongoc-init.c mongoc-libressl.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher.c mongoc-matcher-op.c mongoc-memcmp.c mongoc-opcode.c mongoc-openssl.c mongoc-queue.c mongoc-rand-cng.c mongoc-rand-common-crypto.c mongoc-rand-openssl.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-sasl.c mongoc-scram.c mongoc-secure-channel.c mongoc-secure-transport.c mongoc-server-description.c mongoc-server-stream.c mongoc-set.c mongoc-socket.c mongoc-ssl.c mongoc-stream-buffered.c mongoc-stream.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-socket.c mongoc-stream-tls.c mongoc-stream-tls-libressl.c mongoc-stream-tls-openssl-bio.c mongoc-stream-tls-openssl.c mongoc-stream-tls-secure-channel.c mongoc-stream-tls-secure-transport.c mongoc-topology.c mongoc-topology-description-apm.c mongoc-topology-description.c mongoc-topology-scanner.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-concern.c";
EXTENSION("mongodb", "php_phongo.c phongo_compat.c", null, PHP_MONGODB_CFLAGS);
ADD_SOURCES(configure_module_dirname + "/src", "bson.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/BSON", "Type.c Unserializable.c Serializable.c Persistable.c Binary.c Decimal128.c Javascript.c MaxKey.c MinKey.c ObjectID.c Regex.c Timestamp.c UTCDateTime.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/MongoDB", "Command.c Cursor.c CursorId.c Manager.c Query.c ReadConcern.c ReadPreference.c Server.c BulkWrite.c WriteConcern.c WriteConcernError.c WriteError.c WriteResult.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Exception", "Exception.c LogicException.c RuntimeException.c UnexpectedValueException.c InvalidArgumentException.c ConnectionException.c AuthenticationException.c SSLConnectionException.c ExecutionTimeoutException.c ConnectionTimeoutException.c WriteException.c BulkWriteException.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libbson/src/yajl", "yajl_version.c yajl.c yajl_encode.c yajl_lex.c yajl_parser.c yajl_buf.c yajl_tree.c yajl_alloc.c yajl_gen.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libbson/src/bson", "bcon.c bson.c bson-atomic.c bson-clock.c bson-context.c bson-decimal128.c bson-error.c bson-iter.c bson-iso8601.c bson-json.c bson-keys.c bson-md5.c bson-memory.c bson-oid.c bson-reader.c bson-string.c bson-timegm.c bson-utf8.c bson-value.c bson-version-functions.c bson-writer.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-apm.c mongoc-array.c mongoc-async.c mongoc-async-cmd.c mongoc-buffer.c mongoc-bulk-operation.c mongoc-b64.c mongoc-client.c mongoc-client-pool.c mongoc-cluster.c mongoc-collection.c mongoc-counters.c mongoc-cursor.c mongoc-cursor-array.c mongoc-cursor-cursorid.c mongoc-cursor-transform.c mongoc-database.c mongoc-find-and-modify.c mongoc-host-list.c mongoc-init.c mongoc-gridfs.c mongoc-gridfs-file.c mongoc-gridfs-file-page.c mongoc-gridfs-file-list.c mongoc-handshake.c mongoc-index.c mongoc-linux-distro-scanner.c mongoc-list.c mongoc-log.c mongoc-matcher-op.c mongoc-matcher.c mongoc-memcmp.c mongoc-opcode.c mongoc-queue.c mongoc-read-concern.c mongoc-read-prefs.c mongoc-rpc.c mongoc-server-description.c mongoc-server-stream.c mongoc-set.c mongoc-socket.c mongoc-stream.c mongoc-stream-buffered.c mongoc-stream-file.c mongoc-stream-gridfs.c mongoc-stream-socket.c mongoc-topology.c mongoc-topology-description.c mongoc-topology-description-apm.c mongoc-topology-scanner.c mongoc-uri.c mongoc-util.c mongoc-version-functions.c mongoc-write-command.c mongoc-write-concern.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-crypto.c mongoc-scram.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-stream-tls.c mongoc-ssl.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-crypto-openssl.c mongoc-rand-openssl.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-openssl.c mongoc-stream-tls-openssl.c mongoc-stream-tls-openssl-bio.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-crypto-common-crypto.c mongoc-rand-common-crypto.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-secure-transport.c mongoc-stream-tls-secure-transport.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-crypto-cng.c mongoc-rand-cng.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-secure-channel.c mongoc-stream-tls-secure-channel.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", "mongoc-sasl.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/BSON", "Binary.c Decimal128.c Javascript.c MaxKey.c MinKey.c ObjectID.c Persistable.c Regex.c Serializable.c Timestamp.c Type.c Unserializable.c UTCDateTime.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/MongoDB", "BulkWrite.c Command.c Cursor.c CursorId.c Manager.c Query.c ReadConcern.c ReadPreference.c Server.c WriteConcern.c WriteConcernError.c WriteError.c WriteResult.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/MongoDB/Exception", "AuthenticationException.c BulkWriteException.c ConnectionException.c ConnectionTimeoutException.c Exception.c ExecutionTimeoutException.c InvalidArgumentException.c LogicException.c RuntimeException.c SSLConnectionException.c UnexpectedValueException.c WriteException.c", "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libbson/src/bson", PHP_MONGODB_BSON_SOURCES, "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libbson/src/yajl", PHP_MONGODB_YAJL_SOURCES, "mongodb");
ADD_SOURCES(configure_module_dirname + "/src/libmongoc/src/mongoc", PHP_MONGODB_MONGOC_SOURCES, "mongodb");
var bson_opts = {
BSON_BYTE_ORDER: 1234,
......
......@@ -83,6 +83,7 @@
#endif
# define SIZEOF_PHONGO_LONG SIZEOF_ZEND_LONG
# define phongo_create_object_retval zend_object*
# define phongo_get_gc_table zval **
# define PHONGO_ALLOC_OBJECT_T(_obj_t, _class_type) (_obj_t *)ecalloc(1, sizeof(_obj_t)+zend_object_properties_size(_class_type))
# define PHONGO_TSRMLS_FETCH_FROM_CTX(user_data)
# define SUPPRESS_UNUSED_WARNING(x)
......@@ -112,6 +113,7 @@
# define SIZEOF_PHONGO_LONG SIZEOF_LONG
# define ZSTR_VAL(str) str
# define phongo_create_object_retval zend_object_value
# define phongo_get_gc_table zval ***
# define PHONGO_ALLOC_OBJECT_T(_obj_t, _class_type) (_obj_t *)ecalloc(1, sizeof(_obj_t))
# define PHONGO_TSRMLS_FETCH_FROM_CTX(user_data) TSRMLS_FETCH_FROM_CTX(user_data)
# define SUPPRESS_UNUSED_WARNING(x) (void)x;
......
......@@ -41,6 +41,14 @@
# include <ext/standard/php_smart_str.h>
#endif
/* getpid() */
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef PHP_WIN32
# include <process.h>
#endif