Ticket #7391: 7391.r8483.diff

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

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

Line 
1Index: pluggable.php
2===================================================================
3--- pluggable.php       (revision 8483)
4+++ pluggable.php       (working copy)
5@@ -1512,9 +1512,17 @@
6        $defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' );
7        $args = wp_parse_args( $args, $defaults );
8 
9-       // PEAR Text_Diff is lame; it includes things from include_path rather than it's own path.
10-       // Not sure of the ramifications of disttributing modified code.
11-       ini_set('include_path', '.' . PATH_SEPARATOR . ABSPATH . WPINC );
12+       // PEAR Text_Diff depends on the include path matching its directory structure.
13+       // This prevents modifying source code and maintaining the modifications when
14+       // the package is updated.
15+       // If include_path can not be set, then bail.
16+       if( function_exists('set_include_path') ) {
17+               set_include_path( get_include_path() . PATH_SEPARATOR . ABSPATH . WPINC );
18+       } else if( function_exists('ini_set') ) {
19+               ini_set('include_path', '.' . PATH_SEPARATOR . ABSPATH . WPINC );
20+       } else {
21+               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.');
22+       }
23 
24        if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) )
25                require( ABSPATH . WPINC . '/wp-diff.php' );
26@@ -1534,7 +1542,11 @@
27        $renderer  = new WP_Text_Diff_Renderer_Table();
28        $diff = $renderer->render($text_diff);
29 
30-       ini_restore('include_path');
31+       if( function_exists('restore_include_path') ) {
32+               restore_include_path();
33+       } else if( function_exists('ini_restore') ) {
34+               ini_restore('include_path');
35+       }
36 
37        if ( !$diff )
38                return '';