Branch: refs/heads/3.6
  Home:   https://github.com/OpenSIPS/opensips
  Commit: 707405eb4eb4726575e58f9e1acc918ab3f431fa
      
https://github.com/OpenSIPS/opensips/commit/707405eb4eb4726575e58f9e1acc918ab3f431fa
  Author: Peter Lemenkov <[email protected]>
  Date:   2026-01-27 (Tue, 27 Jan 2026)

  Changed paths:
    M modules/cachedb_mongodb/cachedb_mongodb_dbase.c

  Log Message:
  -----------
  Fix libbson deprecated API warning with version compatibility (#3792)

During compilation of cachedb_mongodb module, numerous deprecation
warnings appear on systems with mongo-c-driver >= 1.29.0:

```
Compiling cachedb_mongodb_dbase.c
gcc -fPIC -DPIC -O2 -flto=auto -ffat-lto-objects -fexceptions -g 
-grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang 
-Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 
-Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 
-fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 
-march=x86-64 -mtune=generic -fasynchronous-unwind-tables 
-fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 
-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer 
-DMOD_NAME='cachedb_mongodb' -DPKG_MALLOC  -DSHM_MMAP  -DUSE_MCAST  
-DDISABLE_NAGLE  -DSTATISTICS  -DHAVE_RESOLV_RES  -DF_MALLOC  -DQ_MALLOC  
-DHP_MALLOC  -DDBG_MALLOC  -DF_PARALLEL_MALLOC  -DHAVE_STDATOMIC 
-DHAVE_GENERICS  -DNAME='"opensips"' -DVERSION='"3.6.2"' -DARCH='"x86_64"' 
-DOS='"linux"' -DCOMPILER='"gcc 15"' -D__CPU_x86_64 -D__OS_linux -D__SMP_yes 
-DCFG_DIR='"/etc/opensips/"'  -DVERSIONTYPE='"git"' 
-DTHISREVISION='"994bcd690"' -DFAST_LOCK -DADAPTIVE_WAIT 
-DADAPTIVE_WAIT_LOOPS=1024 -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN 
-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H -DHAVE_TIMEGM 
-DHAVE_EPOLL -DHAVE_SIGIO_RT -DHAVE_SELECT -I/usr/include/json-c 
-I/usr/include/json-c -DJSON_PKG_MAJOR=0 -DJSON_PKG_MINOR=18 -DJSON_PKG_MICRO=0 
-DUTF8PROC_EXPORTS -I/usr/include/libmongoc-1.0 -I/usr/include/libbson-1.0 -c 
cachedb_mongodb_dbase.c -o cachedb_mongodb_dbase.o
cachedb_mongodb_dbase.c: In function ‘mongo_con_set’:
cachedb_mongodb_dbase.c:315:9: warning: ‘bson_as_json’ is deprecated: Use 
bson_as_legacy_extended_json instead [-Wdeprecated-declarations]
  315 |         dbg_bson("query: ", query);
      |         ^~~~~~~~
In file included from /usr/include/libmongoc-1.0/mongoc/mongoc.h:22,
                 from /usr/include/libmongoc-1.0/mongoc.h:18,
                 from cachedb_mongodb_dbase.h:30,
                 from cachedb_mongodb_dbase.c:22:
/usr/include/libbson-1.0/bson/bson.h:535:1: note: declared here
  535 | bson_as_json (const bson_t *bson, size_t *length) 
BSON_GNUC_DEPRECATED_FOR (bson_as_legacy_extended_json);
      | ^~~~~~~~~~~~
```

The MongoDB C driver (libbson) deprecated bson_as_json() in version
1.29.0 (October 2024) in favor of bson_as_legacy_extended_json() to
clarify which JSON format is being produced (legacy vs. canonical
extended JSON).

We added compatibility macro at the top of cachedb_mongodb_dbase.c - for
mongo-c-driver < 1.29.0, define bson_as_legacy_extended_json as an alias
to bson_as_json, allowing the code to use the new API name while
maintaining backward compatibility.

This change maintains compatibility with all mongo-c-driver versions.
The new function name is used on >= 1.29.0, while older versions
transparently use the original bson_as_json() through the macro alias.

No behavioral changes - the replacement is functionally identical and
produces the same JSON output format. The new name simply makes it
explicit that the legacy extended JSON format is being used.

Note: mongo-c-driver 1.29.0 was released in October 2024. Many LTS
distributions still ship earlier versions (e.g., RHEL 8/9, Ubuntu
20.04/22.04, Debian 11/12), making the compatibility macro necessary.

Assisted-by: Claude (Anthropic) <https://claude.ai>

Signed-off-by: Peter Lemenkov <[email protected]>
(cherry picked from commit dead516b7f4b0881f99afbee4b48969ceaab1d73)



To unsubscribe from these emails, change your notification settings at 
https://github.com/OpenSIPS/opensips/settings/notifications

_______________________________________________
Devel mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/devel

Reply via email to