WordPress.org

Make WordPress Core

Ticket #7391: 7391.r8483.diff

File 7391.r8483.diff, 1.6 KB (added by jacobsantos, 6 years ago)

Use set_include_path() and restore_include_path() based off of r8483

  • pluggable.php

     
    15121512        $defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' ); 
    15131513        $args = wp_parse_args( $args, $defaults ); 
    15141514 
    1515         // PEAR Text_Diff is lame; it includes things from include_path rather than it's own path. 
    1516         // Not sure of the ramifications of disttributing modified code. 
    1517         ini_set('include_path', '.' . PATH_SEPARATOR . ABSPATH . WPINC ); 
     1515        // PEAR Text_Diff depends on the include path matching its directory structure. 
     1516        // This prevents modifying source code and maintaining the modifications when 
     1517        // the package is updated. 
     1518        // If include_path can not be set, then bail. 
     1519        if( function_exists('set_include_path') ) { 
     1520                set_include_path( get_include_path() . PATH_SEPARATOR . ABSPATH . WPINC ); 
     1521        } else if( function_exists('ini_set') ) { 
     1522                ini_set('include_path', '.' . PATH_SEPARATOR . ABSPATH . WPINC ); 
     1523        } else { 
     1524                return __('Error: Setting the include path is disabled on your server. Post revisions cannot be displayed. Please contact your hosting company to resolve this error.'); 
     1525        } 
    15181526 
    15191527        if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) ) 
    15201528                require( ABSPATH . WPINC . '/wp-diff.php' ); 
     
    15341542        $renderer  = new WP_Text_Diff_Renderer_Table(); 
    15351543        $diff = $renderer->render($text_diff); 
    15361544 
    1537         ini_restore('include_path'); 
     1545        if( function_exists('restore_include_path') ) { 
     1546                restore_include_path(); 
     1547        } else if( function_exists('ini_restore') ) { 
     1548                ini_restore('include_path'); 
     1549        } 
    15381550 
    15391551        if ( !$diff ) 
    15401552                return '';