@@ -280,16 +280,39 @@ static ZEND_FUNCTION(zend_get_current_func_name)
280280}
281281
282282#if defined(HAVE_LIBXML ) && !defined(PHP_WIN32 )
283+
284+ /* This test relies on deprecated code to modify the global state of libxml.
285+ * We cannot include the libxml header here as that would create a dependency on libxml from zend_test.
286+ * On 8.2+ this uses ZEND_DIAGNOSTIC_IGNORED_START, but this doesn't exist on 8.1 */
287+ #if defined(__clang__ )
288+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_START \
289+ _Pragma("clang diagnostic push") \
290+ _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
291+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_END \
292+ _Pragma("clang diagnostic pop")
293+ #elif defined(__GNUC__ )
294+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_START \
295+ _Pragma("GCC diagnostic push") \
296+ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
297+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_END \
298+ _Pragma("GCC diagnostic pop")
299+ #else
300+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_START
301+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_END
302+ #endif
303+
283304static ZEND_FUNCTION (zend_test_override_libxml_global_state )
284305{
285306 ZEND_PARSE_PARAMETERS_NONE ();
286307
308+ PHP_LIBXML_IGNORE_DEPRECATIONS_START
287309 xmlLoadExtDtdDefaultValue = 1 ;
288310 xmlDoValidityCheckingDefaultValue = 1 ;
289311 (void ) xmlPedanticParserDefault (1 );
290312 (void ) xmlSubstituteEntitiesDefault (1 );
291313 (void ) xmlLineNumbersDefault (1 );
292314 (void ) xmlKeepBlanksDefault (0 );
315+ PHP_LIBXML_IGNORE_DEPRECATIONS_END
293316}
294317#endif
295318
0 commit comments