From 4550488c991eeb65c34a0ea74602279fe4a7f516 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 14 Jan 2019 05:04:12 +0000 Subject: [PATCH] Widgets: Don't log invalid HTML in the Text Widget. [41215] supresses these irrelevant error messages from the front end, this removes them from the error log, too. Props jeherve. Fixes #43815. git-svn-id: https://develop.svn.wordpress.org/trunk@44578 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/widgets/class-wp-widget-text.php | 5 +++++ tests/phpunit/tests/widgets/text-widget.php | 1 + 2 files changed, 6 insertions(+) diff --git a/src/wp-includes/widgets/class-wp-widget-text.php b/src/wp-includes/widgets/class-wp-widget-text.php index b4f4aa2b99..8db1735198 100644 --- a/src/wp-includes/widgets/class-wp-widget-text.php +++ b/src/wp-includes/widgets/class-wp-widget-text.php @@ -120,6 +120,9 @@ class WP_Widget_Text extends WP_Widget { } $doc = new DOMDocument(); + + // Suppress warnings generated by loadHTML + $errors = libxml_use_internal_errors( true ); @$doc->loadHTML( sprintf( '%s', @@ -127,6 +130,8 @@ class WP_Widget_Text extends WP_Widget { $instance['text'] ) ); + libxml_use_internal_errors( $errors ); + $body = $doc->getElementsByTagName( 'body' )->item( 0 ); // See $allowedposttags. diff --git a/tests/phpunit/tests/widgets/text-widget.php b/tests/phpunit/tests/widgets/text-widget.php index 796a766794..64146a44a3 100644 --- a/tests/phpunit/tests/widgets/text-widget.php +++ b/tests/phpunit/tests/widgets/text-widget.php @@ -572,6 +572,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase { $legacy_text_examples = array( '', '
Quote
Citation
', + '', '', "", '',