WordPress.org

Make WordPress Core

Ticket #37122: 37122.diff

File 37122.diff, 2.6 KB (added by kraftbj, 3 years ago)

Check for xml_parser_create before use

  • src/wp-admin/link-parse-opml.php

     
    7272}
    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}
    7578$xml_parser = xml_parser_create();
    7679
    7780// Set the functions to handle opening and closing tags
  • src/wp-includes/atomlib.php

     
    121121
    122122        array_unshift($this->ns_contexts, array());
    123123
     124        if ( ! function_exists( 'xml_parser_create' ) ) {
     125                trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );
     126        }
     127
    124128        $parser = xml_parser_create_ns();
    125129        xml_set_object($parser, $this);
    126130        xml_set_element_handler($parser, "start_element", "end_element");
  • src/wp-includes/class-IXR.php

     
    219219                self::__construct( $message );
    220220        }
    221221
    222     function parse()
    223     {
     222    function parse() {
     223        if ( ! function_exists( 'xml_parser_create' ) ) {
     224            trigger_error( __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML" ) );
     225        }
     226
    224227        // first remove the XML declaration
    225228        // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages
    226229        $header = preg_replace( '/<\?xml.*?\?'.'>/s', '', substr( $this->message, 0, 100 ), 1 );
     
    12201223        return parent::query('system.multicall', $this->calls);
    12211224    }
    12221225}
     1226
  • src/wp-includes/feed.php

     
    538538                return array('text', $data);
    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
    541545        $parser = xml_parser_create();
    542546        xml_parse($parser, '<div>' . $data . '</div>', true);
    543547        $code = xml_get_error_code($parser);