From: Nikita Popov Date: Thu, 25 Jun 2020 13:24:01 +0000 (+0200) Subject: Don't throw warning if exception thrown during dom validation X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c9bc7dd110714be7d6d6e73184e21280f3896816;p=php Don't throw warning if exception thrown during dom validation --- diff --git a/ext/dom/document.c b/ext/dom/document.c index 89f6358775..aa1d99ebd2 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1681,7 +1681,9 @@ static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type sptr = xmlSchemaParse(parser); xmlSchemaFreeParserCtxt(parser); if (!sptr) { - php_error_docref(NULL, E_WARNING, "Invalid Schema"); + if (!EG(exception)) { + php_error_docref(NULL, E_WARNING, "Invalid Schema"); + } RETURN_FALSE; } diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index 85eaf7a026..d77f6aa2fd 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -485,7 +485,6 @@ static void php_libxml_internal_error_handler(int error_type, void *ctx, const c char *buf; int len, len_iter, output = 0; - len = vspprintf(&buf, 0, *msg, ap); len_iter = len; @@ -502,7 +501,8 @@ static void php_libxml_internal_error_handler(int error_type, void *ctx, const c if (output == 1) { if (LIBXML(error_list)) { _php_list_set_error_structure(NULL, ZSTR_VAL(LIBXML(error_buffer).s)); - } else { + } else if (!EG(exception)) { + /* Don't throw additional notices/warnings if an exception has already been thrown. */ switch (error_type) { case PHP_LIBXML_CTX_ERROR: php_libxml_ctx_error_level(E_WARNING, ctx, ZSTR_VAL(LIBXML(error_buffer).s)); diff --git a/ext/libxml/tests/libxml_set_external_entity_loader_error1.phpt b/ext/libxml/tests/libxml_set_external_entity_loader_error1.phpt index ea0764f980..70aa9ceaa4 100644 --- a/ext/libxml/tests/libxml_set_external_entity_loader_error1.phpt +++ b/ext/libxml/tests/libxml_set_external_entity_loader_error1.phpt @@ -20,9 +20,7 @@ try { } echo "Done.\n"; ---EXPECTF-- +--EXPECT-- bool(true) - -Warning: DOMDocument::validate(): Could not load the external subset "http://example.com/foobar" in %s on line %d Exception: Too few arguments to function {closure}(), 3 passed and exactly 4 expected Done.