General: Check to see that the PHP-XML module is enabled before using XML functions.

There are a handful of places where we don't check that the XML functions exist before we use them. Ubuntu's PHP 7 packages don't include PHP-XML by default, increasing the chance of this causing issues.

Props kraftbj, markoheijnen.
Fixes #37122.



git-svn-id: https://develop.svn.wordpress.org/trunk@38883 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
pento
2016-10-24 04:44:07 +00:00
parent 1377523033
commit 2e9b3c22d8
5 changed files with 26 additions and 7 deletions
+6
View File
@@ -538,6 +538,12 @@ function prep_atom_text_construct($data) {
return array('text', $data);
}
if ( ! function_exists( 'xml_parser_create' ) ) {
trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );
return array( 'html', "<![CDATA[$data]]>" );
}
$parser = xml_parser_create();
xml_parse($parser, '<div>' . $data . '</div>', true);
$code = xml_get_error_code($parser);