WordPress.org

Make WordPress Core

Changeset 38883


Ignore:
Timestamp:
10/24/16 04:44:07 (9 months ago)
Author:
pento
Message:

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.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/link-parse-opml.php

    r32642 r38883  
    7373 
    7474// Create an XML parser 
     75if ( ! function_exists( 'xml_parser_create' ) ) { 
     76    trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) ); 
     77    wp_die( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) ); 
     78} 
     79 
    7580$xml_parser = xml_parser_create(); 
    7681 
  • trunk/src/wp-includes/IXR/class-IXR-message.php

    r38389 r38883  
    4545    function parse() 
    4646    { 
     47        if ( ! function_exists( 'xml_parser_create' ) ) { 
     48            trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML" ) ); 
     49            return false; 
     50        } 
     51 
    4752        // first remove the XML declaration 
    4853        // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages 
  • trunk/src/wp-includes/atomlib.php

    r37461 r38883  
    121121 
    122122        array_unshift($this->ns_contexts, array()); 
     123 
     124        if ( ! function_exists( 'xml_parser_create_ns' ) ) { 
     125            trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) ); 
     126            return false; 
     127        } 
    123128 
    124129        $parser = xml_parser_create_ns(); 
  • trunk/src/wp-includes/feed.php

    r38470 r38883  
    539539    } 
    540540 
     541    if ( ! function_exists( 'xml_parser_create' ) ) { 
     542        trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) ); 
     543 
     544        return array( 'html', "<![CDATA[$data]]>" ); 
     545    } 
     546 
    541547    $parser = xml_parser_create(); 
    542548    xml_parse($parser, '<div>' . $data . '</div>', true); 
  • trunk/src/wp-includes/rss.php

    r37985 r38883  
    6161    function __construct( $source ) { 
    6262 
    63         # if PHP xml isn't compiled in, die 
     63        # Check if PHP xml isn't compiled 
    6464        # 
    65         if ( !function_exists('xml_parser_create') ) 
    66             trigger_error( "Failed to load PHP's XML Extension. https://secure.php.net/manual/en/ref.xml.php" ); 
    67  
    68         $parser = @xml_parser_create(); 
    69  
    70         if ( !is_resource($parser) ) 
    71             trigger_error( "Failed to create an instance of PHP's XML parser. https://secure.php.net/manual/en/ref.xml.php"); 
     65        if ( ! function_exists('xml_parser_create') ) { 
     66            return trigger_error( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ); 
     67        } 
     68 
     69        $parser = xml_parser_create(); 
    7270 
    7371        $this->parser = $parser; 
Note: See TracChangeset for help on using the changeset viewer.