From 1cd49e2d4d8ab459ff9fe00e36a8c0195120f84f Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 22 Oct 2015 16:38:26 +0000 Subject: [PATCH] oEmbed: if `SimpleXMLElement` does not exist, return an `HTTP Error 501 Not implemented` response. Props swissspidy. Fixes #34274. Built from https://develop.svn.wordpress.org/trunk@35354 git-svn-id: http://core.svn.wordpress.org/trunk@35320 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-oembed-controller.php | 7 ++++++- wp-includes/embed-functions.php | 5 ++++- wp-includes/version.php | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/wp-includes/class-wp-oembed-controller.php b/wp-includes/class-wp-oembed-controller.php index 2da7f3e5db..22c062be9f 100644 --- a/wp-includes/class-wp-oembed-controller.php +++ b/wp-includes/class-wp-oembed-controller.php @@ -142,12 +142,17 @@ final class WP_oEmbed_Controller { * @return string The XML response data. */ public function xml_response( $data ) { + if ( ! class_exists( 'SimpleXMLElement' ) ) { + status_header( 501 ); + return get_status_header_desc( 501 ); + } + $result = _oembed_create_xml( $data ); // Bail if there's no XML. if ( ! $result ) { status_header( 501 ); - return 'Not implemented'; + return get_status_header_desc( 501 ); } if ( ! headers_sent() ) { diff --git a/wp-includes/embed-functions.php b/wp-includes/embed-functions.php index fa796ac791..e5837cf453 100644 --- a/wp-includes/embed-functions.php +++ b/wp-includes/embed-functions.php @@ -351,7 +351,10 @@ function wp_oembed_add_discovery_links() { if ( is_singular() ) { $output .= '' . "\n"; - $output .= '' . "\n"; + + if ( class_exists( 'SimpleXMLElement' ) ) { + $output .= '' . "\n"; + } } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index d98b312604..207b32c408 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-35353'; +$wp_version = '4.4-alpha-35354'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.