Skip to content

Commit 8a8dc74

Browse files
committed
Merged pull request #690
2 parents 2f1f6b9 + 0c193eb commit 8a8dc74

File tree

4 files changed

+64
-1
lines changed

4 files changed

+64
-1
lines changed

config.m4

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,18 @@ if test "$MONGODB" != "no"; then
380380
enable_srv=auto
381381
m4_include(src/libmongoc/build/autotools/FindResSearch.m4)
382382

383+
with_snappy=auto
384+
with_zlib=auto
385+
m4_include(src/libmongoc/build/autotools/m4/pkg.m4)
386+
m4_include(src/libmongoc/build/autotools/CheckSnappy.m4)
387+
m4_include(src/libmongoc/build/autotools/CheckZlib.m4)
388+
389+
if test "x$with_zlib" != "xno" -o "x$with_snappy" != "xno"; then
390+
AC_SUBST(MONGOC_ENABLE_COMPRESSION, 1)
391+
else
392+
AC_SUBST(MONGOC_ENABLE_COMPRESSION, 0)
393+
fi
394+
383395
m4_include(src/libmongoc/build/autotools/WeakSymbols.m4)
384396
m4_include(src/libmongoc/build/autotools/m4/ax_pthread.m4)
385397
AX_PTHREAD
@@ -391,7 +403,7 @@ if test "$MONGODB" != "no"; then
391403
PHP_SUBST(EXTRA_CFLAGS)
392404
PHP_SUBST(EXTRA_LDFLAGS)
393405

394-
MONGODB_SHARED_LIBADD="$MONGODB_SHARED_LIBADD $PTHREAD_LIBS $SASL_LIBS"
406+
MONGODB_SHARED_LIBADD="$MONGODB_SHARED_LIBADD $PTHREAD_LIBS $SASL_LIBS $SNAPPY_LIBS $ZLIB_LIBS"
395407
PHP_SUBST(MONGODB_SHARED_LIBADD)
396408

397409
PHP_NEW_EXTENSION(mongodb, $PHP_MONGODB_SOURCES, $ext_shared,, $PHP_MONGODB_CFLAGS)

php_phongo.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,6 +1394,20 @@ static bool php_phongo_apply_options_to_uri(mongoc_uri_t *uri, bson_t *options T
13941394

13951395
continue;
13961396
}
1397+
1398+
if (!strcasecmp(key, MONGOC_URI_COMPRESSORS)) {
1399+
if (!BSON_ITER_HOLDS_UTF8(&iter)) {
1400+
PHONGO_URI_INVALID_TYPE(iter, "string");
1401+
return false;
1402+
}
1403+
1404+
if (!mongoc_uri_set_compressors(uri, bson_iter_utf8(&iter, NULL))) {
1405+
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Failed to parse \"%s\" URI option", key);
1406+
return false;
1407+
}
1408+
1409+
continue;
1410+
}
13971411
}
13981412

13991413
return true;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
MongoDB\Driver\Manager: Connecting with unsupported compressor
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php NEEDS('STANDALONE'); ?>
6+
--FILE--
7+
<?php
8+
require_once __DIR__ . "/../utils/basic.inc";
9+
10+
ini_set('mongodb.debug', 'stdout');
11+
$manager = new MongoDB\Driver\Manager(STANDALONE, [ 'compressors' => 'zli'] );
12+
ini_set('mongodb.debug', null);
13+
?>
14+
===DONE===
15+
<?php exit(0); ?>
16+
--EXPECTF--
17+
%AWARNING > Unsupported compressor: 'zli'%A
18+
===DONE===
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
MongoDB\Driver\Manager: Connecting with invalid compressor values
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php NEEDS('STANDALONE'); ?>
6+
--FILE--
7+
<?php
8+
require_once __DIR__ . "/../utils/basic.inc";
9+
10+
echo throws(function() {
11+
$manager = new MongoDB\Driver\Manager(STANDALONE, [ 'compressors' => "foo\xFEbar"] );
12+
}, 'MongoDB\Driver\Exception\UnexpectedValueException'), "\n";
13+
?>
14+
===DONE===
15+
<?php exit(0); ?>
16+
--EXPECTF--
17+
OK: Got MongoDB\Driver\Exception\UnexpectedValueException
18+
Detected invalid UTF-8 for fieldname "compressors": %s
19+
===DONE===

0 commit comments

Comments
 (0)