@@ -119,28 +119,49 @@ PHP_LIBXML_API void php_libxml_shutdown(void);
119119ZEND_TSRMLS_CACHE_EXTERN ()
120120#endif
121121
122+ #if defined(__clang__ )
123+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_START \
124+ _Pragma("clang diagnostic push") \
125+ _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
126+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_END \
127+ _Pragma("clang diagnostic pop")
128+ #elif defined(__GNUC__ )
129+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_START \
130+ _Pragma("GCC diagnostic push") \
131+ _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
132+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_END \
133+ _Pragma("GCC diagnostic pop")
134+ #else
135+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_START
136+ # define PHP_LIBXML_IGNORE_DEPRECATIONS_END
137+ #endif
138+
122139/* Other extension may override the global state options, these global options
123140 * are copied initially to ctxt->options. Set the options to a known good value.
124141 * See libxml2 globals.c and parserInternals.c.
125142 * The unique_name argument allows multiple sanitizes and restores within the
126143 * same function, even nested is necessary. */
127144#define PHP_LIBXML_SANITIZE_GLOBALS (unique_name ) \
145+ PHP_LIBXML_IGNORE_DEPRECATIONS_START \
128146 int xml_old_loadsubset_##unique_name = xmlLoadExtDtdDefaultValue; \
129147 xmlLoadExtDtdDefaultValue = 0; \
130148 int xml_old_validate_##unique_name = xmlDoValidityCheckingDefaultValue; \
131149 xmlDoValidityCheckingDefaultValue = 0; \
132150 int xml_old_pedantic_##unique_name = xmlPedanticParserDefault(0); \
133151 int xml_old_substitute_##unique_name = xmlSubstituteEntitiesDefault(0); \
134152 int xml_old_linenrs_##unique_name = xmlLineNumbersDefault(0); \
135- int xml_old_blanks_##unique_name = xmlKeepBlanksDefault(1);
153+ int xml_old_blanks_##unique_name = xmlKeepBlanksDefault(1); \
154+ PHP_LIBXML_IGNORE_DEPRECATIONS_END
136155
137156#define PHP_LIBXML_RESTORE_GLOBALS (unique_name ) \
157+ PHP_LIBXML_IGNORE_DEPRECATIONS_START \
138158 xmlLoadExtDtdDefaultValue = xml_old_loadsubset_##unique_name; \
139159 xmlDoValidityCheckingDefaultValue = xml_old_validate_##unique_name; \
140160 (void) xmlPedanticParserDefault(xml_old_pedantic_##unique_name); \
141161 (void) xmlSubstituteEntitiesDefault(xml_old_substitute_##unique_name); \
142162 (void) xmlLineNumbersDefault(xml_old_linenrs_##unique_name); \
143- (void) xmlKeepBlanksDefault(xml_old_blanks_##unique_name);
163+ (void) xmlKeepBlanksDefault(xml_old_blanks_##unique_name); \
164+ PHP_LIBXML_IGNORE_DEPRECATIONS_END
144165
145166/* Alternative for above, working directly on the context and not setting globals.
146167 * 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