Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ PHP_ARG_WITH(libbson, Use system libbson,
fi
PHP_EVAL_INCLINE($LIBBSON_INC)
PHP_EVAL_LIBLINE($LIBBSON_LIB, MONGODB_SHARED_LIBADD)
AC_DEFINE(HAVE_SYSTEM_LIBBSON, 1, [Use system libbson])
else
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libbson/src/yajl], $YAJL_SOURCES, [$STD_CFLAGS $MAINTAINER_CFLAGS], shared_objects_mongodb, yes)
PHP_ADD_SOURCES_X(PHP_EXT_DIR(mongodb)[src/libbson/src/bson], $BSON_SOURCES, [$STD_CFLAGS $MAINTAINER_CFLAGS], shared_objects_mongodb, yes)
Expand All @@ -331,21 +332,22 @@ PHP_ARG_WITH(libmongoc, Use system libmongoc,
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
AC_MSG_CHECKING(for libmongoc)
if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libmongoc-1.0 && $PKG_CONFIG --exists libmongoc-priv; then
if $PKG_CONFIG libmongoc-1.0 --atleast-version 1.1.5; then
if $PKG_CONFIG libmongoc-1.0 --atleast-version 1.2.0; then
LIBMONGOC_INC=`$PKG_CONFIG libmongoc-priv --cflags`
LIBMONGOC_LIB=`$PKG_CONFIG libmongoc-priv --libs`
LIBMONGOC_VER=`$PKG_CONFIG libmongoc-priv --modversion`
AC_MSG_RESULT(version $LIBMONGOC_VER found)
CFLAGS="$CFLAGS -DMONGOC_I_AM_A_DRIVER"

else
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 1.1.6)
AC_MSG_ERROR(system libmongoc must be upgraded to version >= 1.2.0)
fi
else
AC_MSG_ERROR(pkgconfig and mongoc must be installed)
fi
PHP_EVAL_INCLINE($LIBMONGOC_INC)
PHP_EVAL_LIBLINE($LIBMONGOC_LIB, MONGODB_SHARED_LIBADD)
AC_DEFINE(HAVE_SYSTEM_LIBMONGOC, 1, [Use system libmongoc])
else
CPPFLAGS="$CPPFLAGS -DBSON_COMPILATION -DMONGOC_COMPILATION -DMONGOC_TRACE"

Expand Down
29 changes: 28 additions & 1 deletion php_phongo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1870,7 +1870,23 @@ mongoc_client_t *php_phongo_make_mongo_client(const mongoc_uri_t *uri, zval *dri
php_phongo_populate_default_ssl_ctx(ctx, driverOptions);
}

MONGOC_DEBUG("Creating Manager, phongo-%s[%s] - mongoc-%s, libbson-%s", MONGODB_VERSION_S, MONGODB_STABILITY_S, MONGOC_VERSION_S, BSON_VERSION_S);
MONGOC_DEBUG("Creating Manager, phongo-%s[%s] - mongoc-%s(%s), libbson-%s(%s), php-%s",
MONGODB_VERSION_S,
MONGODB_STABILITY_S,
MONGOC_VERSION_S,
#ifdef HAVE_SYSTEM_LIBMONGOC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to trigger Compiler Error C2121 in VC11, because we're using a macro within the MONGOC_DEBUG() macro. I believe a quick solution would be to populate const char * variables beforehand and use those as-is in the MONGOC_DEBUG() macro.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for this... :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries! I've missed more than my fair share of Windows errors :)

5917787 should fix it.

mongoc_get_version(),
#else
"bundled",
#endif
BSON_VERSION_S,
#ifdef HAVE_SYSTEM_LIBBSON
bson_get_version(),
#else
"bundled",
#endif
PHP_VERSION
);
client = mongoc_client_new_from_uri(uri);

if (!client) {
Expand Down Expand Up @@ -2375,8 +2391,19 @@ PHP_MINFO_FUNCTION(mongodb)
php_info_print_table_header(2, "mongodb support", "enabled");
php_info_print_table_row(2, "mongodb version", MONGODB_VERSION_S);
php_info_print_table_row(2, "mongodb stability", MONGODB_STABILITY_S);
#ifdef HAVE_SYSTEM_LIBMONGOC
php_info_print_table_row(2, "libmongoc headers version", MONGOC_VERSION_S);
php_info_print_table_row(2, "libmongoc library version", mongoc_get_version());
#else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to keep this consistent.
Otherwise we have to ask what does phpinfo() report as "libmongoc headers version and "libmongoc library version" -- or -- libmongoc version?.

Lets just always print out both compile time and lib

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or "libbson bundled version" ?
(I'd like to make explicit if system or bundled library is used, which as some value tyring to help/support our users)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok. Makes sense. Shall we make that the third line? mongoc: system/bundled ?
Then its easy ctrl+fable, along with being straight forward to ask/answer the question

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having 1 line for bundled library and 2 for system library is quite common and consistent with other ext : see GD, msgpack, libsodium ...)... ok.... all added by me ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice: I CANNOT change now, as bson_get_version is not yet defined in bundled lib... (need to wait for PR #119)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hehe. ok. This is such a minor detail that as long as the output isn't vastly different then it isn't worth spending to much time on this.

One thing that just hit me though, maybe we should update the trace line that reports these versions:
https://github.com/mongodb-labs/mongo-php-driver-prototype/blob/master/php_phongo.c#L1873

I am hoping the only question we will ever need to ask users for support cases is:

Can you change your php.ini to include mongodb.debug=/tmp/ and rerun the script as send us the content?

Or

Can you pass array("debug" => "/tmp/") as 3rd argument to the ctor

So it would be nice to know there if it was bundled/system.
See also: https://jira.mongodb.org/browse/PHPC-442

/* Bundled libraries, buildtime = runtime */
php_info_print_table_row(2, "libmongoc version", MONGOC_VERSION_S);
#endif
#ifdef HAVE_SYSTEM_LIBBSON
php_info_print_table_row(2, "libbson headers version", BSON_VERSION_S);
php_info_print_table_row(2, "libbson library version", bson_get_version());
#else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, lets always use this

php_info_print_table_row(2, "libbson version", BSON_VERSION_S);
#endif
php_info_print_table_end();

DISPLAY_INI_ENTRIES();
Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager-debug-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ foreach($content as $line) {
===DONE===
<?php exit(0); ?>
--EXPECTF--
[%s] PHONGO: DEBUG > Creating Manager, phongo-1.%d.%d%S[%s] - mongoc-1.%s, libbson-1.%s
[%s] PHONGO: DEBUG > Creating Manager, phongo-1.%d.%d%S[%s] - mongoc-1.%s(%s), libbson-1.%s(%s), php-%s
[%s] mongoc: TRACE > ENTRY: mongoc_bulk_operation_execute():%d
[%s] mongoc: TRACE > EXIT: mongoc_bulk_operation_execute():%d
===DONE===
2 changes: 1 addition & 1 deletion tests/manager/manager-debug-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ini_set("mongodb.debug", "off");
<?php exit(0); ?>
--EXPECTF--
%a
[%s] PHONGO: DEBUG > Creating Manager, phongo-1.%d.%d%S[%s] - mongoc-1.%s, libbson-1.%s
[%s] PHONGO: DEBUG > Creating Manager, phongo-1.%d.%d%S[%s] - mongoc-1.%s(%s), libbson-1.%s(%s), php-%s
%a
[%s] PHONGO: DEBUG > Connecting to '%s:%d[mongodb://%s:%d]'
%a
Expand Down
2 changes: 1 addition & 1 deletion tests/manager/manager-debug-003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ ini_set("mongodb.debug", "off");
--EXPECTF--
%a
[%s] PHONGO: TRACE > ENTRY: php_phongo_make_mongo_client():%d
[%s] PHONGO: DEBUG > Creating Manager, phongo-1.%d.%d%S[%s] - mongoc-1.%s, libbson-1.%s
[%s] PHONGO: DEBUG > Creating Manager, phongo-1.%d.%d%S[%s] - mongoc-1.%s(%s), libbson-1.%s(%s), php-%s
%a
===DONE===