Skip to content

Commit c9bc7dd

Browse files
committed
Don't throw warning if exception thrown during dom validation
1 parent 049467d commit c9bc7dd

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

ext/dom/document.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,9 @@ static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type
16811681
sptr = xmlSchemaParse(parser);
16821682
xmlSchemaFreeParserCtxt(parser);
16831683
if (!sptr) {
1684-
php_error_docref(NULL, E_WARNING, "Invalid Schema");
1684+
if (!EG(exception)) {
1685+
php_error_docref(NULL, E_WARNING, "Invalid Schema");
1686+
}
16851687
RETURN_FALSE;
16861688
}
16871689

ext/libxml/libxml.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ static void php_libxml_internal_error_handler(int error_type, void *ctx, const c
485485
char *buf;
486486
int len, len_iter, output = 0;
487487

488-
489488
len = vspprintf(&buf, 0, *msg, ap);
490489
len_iter = len;
491490

@@ -502,7 +501,8 @@ static void php_libxml_internal_error_handler(int error_type, void *ctx, const c
502501
if (output == 1) {
503502
if (LIBXML(error_list)) {
504503
_php_list_set_error_structure(NULL, ZSTR_VAL(LIBXML(error_buffer).s));
505-
} else {
504+
} else if (!EG(exception)) {
505+
/* Don't throw additional notices/warnings if an exception has already been thrown. */
506506
switch (error_type) {
507507
case PHP_LIBXML_CTX_ERROR:
508508
php_libxml_ctx_error_level(E_WARNING, ctx, ZSTR_VAL(LIBXML(error_buffer).s));

ext/libxml/tests/libxml_set_external_entity_loader_error1.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ try {
2020
}
2121

2222
echo "Done.\n";
23-
--EXPECTF--
23+
--EXPECT--
2424
bool(true)
25-
26-
Warning: DOMDocument::validate(): Could not load the external subset "http://example.com/foobar" in %s on line %d
2725
Exception: Too few arguments to function {closure}(), 3 passed and exactly 4 expected
2826
Done.

0 commit comments

Comments
 (0)