@@ -232,27 +232,33 @@ if (PHP_MONGODB != "no") {
232232 WARNING ( "mongodb libopenssl support not enabled, libs not found" ) ;
233233 }
234234
235- if ( PHP_MONGODB_SASL != "no" &&
236- CHECK_LIB ( "libsasl.lib" , "mongodb" , PHP_MONGODB ) &&
237- CHECK_HEADER_ADD_INCLUDE ( "sasl/sasl.h" , "CFLAGS_MONGODB" ) ) {
238-
239- // TODO 3.0: Remove warning on "yes" as it implies "sspi"
240- if ( PHP_MONGODB_SASL == "yes" ) {
241- WARNING ( "Cyrus SASL support for Windows was removed. Falling back to SSPI; use '--with-mongodb-sasl=sspi' to avoid this warning." ) ;
242- }
243-
244- if ( PHP_MONGODB_SASL == "yes" || PHP_MONGODB_SASL == "sspi" ) {
245- mongoc_opts . MONGOC_ENABLE_SASL = 1 ;
246- mongoc_opts . MONGOC_ENABLE_SASL_SSPI = 1 ;
235+ has_sasl_libs = CHECK_LIB ( "libsasl.lib" , "mongodb" , PHP_MONGODB ) &&
236+ CHECK_HEADER_ADD_INCLUDE ( "sasl/sasl.h" , "CFLAGS_MONGODB" ) ;
237+ if ( PHP_MONGODB_SASL != "no" ) {
238+ if ( has_sasl_libs ) {
239+ // TODO 3.0: Remove warning on "yes" as it implies "sspi"
240+ if ( PHP_MONGODB_SASL == "yes" ) {
241+ WARNING ( "Cyrus SASL support for Windows was removed. Falling back to SSPI; use '--with-mongodb-sasl=sspi' to avoid this warning." ) ;
242+ PHP_MONGODB_SASL = "sspi" ;
243+ }
244+
245+ if ( PHP_MONGODB_SASL == "sspi" ) {
246+ mongoc_opts . MONGOC_ENABLE_SASL = 1 ;
247+ mongoc_opts . MONGOC_ENABLE_SASL_SSPI = 1 ;
248+ } else {
249+ ERROR ( "MongoDB SASL support not enabled, unknown value for --with-mongodb-sasl: " + PHP_MONGODB_SASL ) ;
250+ }
251+
252+ if ( CHECK_FUNC_IN_HEADER ( "sasl/sasl.h" , "sasl_client_done" ) ) {
253+ mongoc_opts . MONGOC_HAVE_SASL_CLIENT_DONE = 1 ;
254+ }
255+ } else if ( PHP_MONGODB_SASL != "yes" ) {
256+ // If the user explicitly requested SASL support, we error out if the
257+ // necessary libraries are not found.
258+ ERROR ( "MongoDB SASL support not enabled, libs not found" ) ;
247259 } else {
248- ERROR ( "MongoDB SASL support not enabled, unknown value for --with-mongodb-sasl: " + PHP_MONGODB_SASL ) ;
249- }
250-
251- if ( CHECK_FUNC_IN_HEADER ( "sasl/sasl.h" , "sasl_client_done" ) ) {
252- mongoc_opts . MONGOC_HAVE_SASL_CLIENT_DONE = 1 ;
260+ WARNING ( "MongoDB SASL support not enabled, libs not found" ) ;
253261 }
254- } else if ( PHP_MONGODB_SASL != "no" ) {
255- ERROR ( "MongoDB SASL support not enabled, libs not found" ) ;
256262 }
257263
258264 if ( PHP_MONGODB_CLIENT_SIDE_ENCRYPTION != "no" && mongoc_ssl_found ) {
0 commit comments