WordPress.org

Make WordPress Core

Ticket #37122: 37122.3.diff

File 37122.3.diff, 4.5 KB (added by markoheijnen, 3 years ago)
  • src/wp-admin/link-parse-opml.php

     
    7272}
    7373
    7474// Create an XML parser
    75 $xml_parser = xml_parser_create();
     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}
     78else {
     79        $xml_parser = xml_parser_create();
    7680
    77 // Set the functions to handle opening and closing tags
    78 xml_set_element_handler($xml_parser, "startElement", "endElement");
     81        // Set the functions to handle opening and closing tags
     82        xml_set_element_handler($xml_parser, "startElement", "endElement");
    7983
    80 if ( ! xml_parse( $xml_parser, $opml, true ) ) {
    81         printf(
    82                 /* translators: 1: error message, 2: line number */
    83                 __( 'XML Error: %1$s at line %2$s' ),
    84                 xml_error_string( xml_get_error_code( $xml_parser ) ),
    85                 xml_get_current_line_number( $xml_parser )
    86         );
    87 }
     84        if ( ! xml_parse( $xml_parser, $opml, true ) ) {
     85                printf(
     86                        /* translators: 1: error message, 2: line number */
     87                        __( 'XML Error: %1$s at line %2$s' ),
     88                        xml_error_string( xml_get_error_code( $xml_parser ) ),
     89                        xml_get_current_line_number( $xml_parser )
     90                );
     91        }
    8892
    89 // Free up memory used by the XML parser
    90 xml_parser_free($xml_parser);
     93        // Free up memory used by the XML parser
     94        xml_parser_free($xml_parser);
     95}
  • src/wp-includes/IXR/class-IXR-message.php

     
    4444
    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
    4954        $header = preg_replace( '/<\?xml.*?\?'.'>/s', '', substr( $this->message, 0, 100 ), 1 );
  • src/wp-includes/atomlib.php

     
    121121
    122122        array_unshift($this->ns_contexts, array());
    123123
     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
     127            return false;
     128        }
     129
    124130        $parser = xml_parser_create_ns();
    125131        xml_set_object($parser, $this);
    126132        xml_set_element_handler($parser, "start_element", "end_element");
  • 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                return array('html', "<![CDATA[$data]]>");
     545        }
     546
    541547        $parser = xml_parser_create();
    542548        xml_parse($parser, '<div>' . $data . '</div>', true);
    543549        $code = xml_get_error_code($parser);
  • src/wp-includes/rss.php

     
    6060         */
    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" );
     65                if ( ! function_exists('xml_parser_create') ) {
     66                        return trigger_error( "Failed to load PHP's XML Extension. https://secure.php.net/manual/en/ref.xml.php" );
     67                }
    6768
    6869                $parser = @xml_parser_create();
    6970
    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");
     71                if ( ! is_resource($parser) ) {
     72                        return trigger_error( "Failed to create an instance of PHP's XML parser. https://secure.php.net/manual/en/ref.xml.php");
     73                }
    7274
    7375                $this->parser = $parser;
    7476