[wp-trac] [WordPress Trac] #41622: Issue with upgrading text widgets that contain html to 4.8.1
WordPress Trac
noreply at wordpress.org
Sun Aug 13 00:34:43 UTC 2017
#41622: Issue with upgrading text widgets that contain html to 4.8.1
-------------------------------+------------------------------
Reporter: codezen8 | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Widgets | Version: 4.8.1
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses:
-------------------------------+------------------------------
Changes (by westonruter):
* keywords: => reporter-feedback
Comment:
@codezen8 Thanks for the report. Could you provide some the full examples
of text that was in the widgets prior to the upgrade?
So it seems like at the very least we need to add error-suppression for
the `loadHTML` call and specify the HTML5 doctype, like:
{{{#!php
<?php
--- src/wp-includes/widgets/class-wp-widget-text.php
+++ src/wp-includes/widgets/class-wp-widget-text.php
@@ -114,8 +114,8 @@ class WP_Widget_Text extends WP_Widget {
}
$doc = new DOMDocument();
- $doc->loadHTML( sprintf(
+ @$doc->loadHTML( sprintf(
- '<html><head><meta
charset="%s"></head><body>%s</body></html>',
+ '<!DOCTYPE html><html><head><meta
charset="%s"></head><body>%s</body></html>',
esc_attr( get_bloginfo( 'charset' ) ),
$instance['text']
) );
}}}
Otherwise, I'm not clear what else should be done. Maybe detect if there
are HTML parsing warnings and use that as another signal for legacy mode?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41622#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list