@@ -149,28 +149,49 @@ PHP_LIBXML_API void php_libxml_shutdown(void);
149149ZEND_TSRMLS_CACHE_EXTERN ()
150150#endif
151151
152+ #if defined(__clang__ )
153+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_START \
154+ _Pragma("clang diagnostic push") \
155+ _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
156+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_END \
157+ _Pragma("clang diagnostic pop")
158+ #elif defined(__GNUC__ )
159+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_START \
160+ _Pragma("GCC diagnostic push") \
161+ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
162+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_END \
163+ _Pragma("GCC diagnostic pop")
164+ #else
165+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_START
166+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_END
167+ #endif
168+
152169/* Other extension may override the global state options, these global options
153170 * are copied initially to ctxt->options. Set the options to a known good value.
154171 * See libxml2 globals.c and parserInternals.c.
155172 * The unique_name argument allows multiple sanitizes and restores within the
156173 * same function, even nested is necessary. */
157174#define PHP_LIBXML_SANITIZE_GLOBALS (unique_name ) \
175+ PHP_LIBXML_IGNORE_DEPRECATIONS_START \
158176 int xml_old_loadsubset_##unique_name = xmlLoadExtDtdDefaultValue; \
159177 xmlLoadExtDtdDefaultValue = 0; \
160178 int xml_old_validate_##unique_name = xmlDoValidityCheckingDefaultValue; \
161179 xmlDoValidityCheckingDefaultValue = 0; \
162180 int xml_old_pedantic_##unique_name = xmlPedanticParserDefault(0); \
163181 int xml_old_substitute_##unique_name = xmlSubstituteEntitiesDefault(0); \
164182 int xml_old_linenrs_##unique_name = xmlLineNumbersDefault(0); \
165- int xml_old_blanks_##unique_name = xmlKeepBlanksDefault(1);
183+ int xml_old_blanks_##unique_name = xmlKeepBlanksDefault(1); \
184+ PHP_LIBXML_IGNORE_DEPRECATIONS_END
166185
167186#define PHP_LIBXML_RESTORE_GLOBALS (unique_name ) \
187+ PHP_LIBXML_IGNORE_DEPRECATIONS_START \
168188 xmlLoadExtDtdDefaultValue = xml_old_loadsubset_##unique_name; \
169189 xmlDoValidityCheckingDefaultValue = xml_old_validate_##unique_name; \
170190 (void) xmlPedanticParserDefault(xml_old_pedantic_##unique_name); \
171191 (void) xmlSubstituteEntitiesDefault(xml_old_substitute_##unique_name); \
172192 (void) xmlLineNumbersDefault(xml_old_linenrs_##unique_name); \
173- (void) xmlKeepBlanksDefault(xml_old_blanks_##unique_name);
193+ (void) xmlKeepBlanksDefault(xml_old_blanks_##unique_name); \
194+ PHP_LIBXML_IGNORE_DEPRECATIONS_END
174195
175196/* Alternative for above, working directly on the context and not setting globals.
176197 * Generally faster because no locking is involved, and this has the advantage that it sets the options to a known good value. */
0 commit comments