[PHP-CVS] [php-src] master: Fix SNMP build with modern Net-SNMP API (#23419)

[email protected] (Shivam Mathur via GitHub)
Newsgroups php.cvs
Message-ID <[email protected]>
Author: Shivam Mathur (shivammathur)
Committer: GitHub (web-flow)
Pusher: Girgias
Date: 2026-08-23T15:21:40+01:00

Commit: https://github.com/php/php-src/commit/105d6df5e2338c60067a98b39593db544af4e768
Raw diff: https://github.com/php/php-src/commit/105d6df5e2338c60067a98b39593db544af4e768.diff

Fix SNMP build with modern Net-SNMP API (#23419)

Changed paths:
  M  ext/snmp/config.m4
  M  ext/snmp/snmp.c


Diff:

diff --git a/ext/snmp/config.m4 b/ext/snmp/config.m4
index 22cab40adf3b..62ac5471da7a 100644
--- a/ext/snmp/config.m4
+++ b/ext/snmp/config.m4
@@ -51,6 +51,13 @@ if test "$PHP_SNMP" != "no"; then
     [AC_MSG_FAILURE([SNMP sanity check failed.])],
     [$SNMP_SHARED_LIBADD])
 
+  dnl Check whether netsnmp_init_mib() exists.
+  PHP_CHECK_LIBRARY([$SNMP_LIBNAME], [netsnmp_init_mib],
+    [AC_DEFINE([HAVE_NETSNMP_INIT_MIB], [1],
+      [Define to 1 if the Net-SNMP library has the 'netsnmp_init_mib' function.])],
+    [],
+    [$SNMP_SHARED_LIBADD])
+
   dnl Check whether shutdown_snmp_logging() exists.
   PHP_CHECK_LIBRARY([$SNMP_LIBNAME], [shutdown_snmp_logging],
     [AC_DEFINE([HAVE_SHUTDOWN_SNMP_LOGGING], [1],
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
index bcca8d44de89..8fac85a236ab 100644
--- a/ext/snmp/snmp.c
+++ b/ext/snmp/snmp.c
@@ -1687,7 +1687,11 @@ PHP_FUNCTION(snmp_init_mib)
 
 	shutdown_mib();
 	netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS, ZSTR_VAL(mibdirs));
+#ifdef HAVE_NETSNMP_INIT_MIB
+	netsnmp_init_mib();
+#else
 	init_mib();
+#endif
 }
 /* }}} */
 
@@ -2228,7 +2232,11 @@ static PHP_RSHUTDOWN_FUNCTION(snmp)
 	if (mib_needs_reset) {
 		shutdown_mib();
 		netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_MIBDIRS, NULL);
+#ifdef HAVE_NETSNMP_INIT_MIB
+		netsnmp_init_mib();
+#else
 		init_mib();
+#endif
 	}
 
 	return SUCCESS;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.