From b07aca4429fa8d6223420b4dca221d04d9d816b2 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Tue, 5 Aug 2008 23:56:52 +0000 Subject: [PATCH] Stop fatal error in post revisions when setting the include path is disabled. Props santosj, for 2.7 git-svn-id: https://develop.svn.wordpress.org/trunk@8562 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/pluggable.php | 9 +++------ wp-settings.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 9407f1a986..1d78911e06 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -1527,13 +1527,12 @@ if ( !function_exists( 'wp_text_diff' ) ) : * @return string Empty string if strings are equivalent or HTML with differences. */ function wp_text_diff( $left_string, $right_string, $args = null ) { + if ( defined( 'WP_INCLUDE_PATH_DISABLED' ) ) + return ''; + $defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' ); $args = wp_parse_args( $args, $defaults ); - // PEAR Text_Diff is lame; it includes things from include_path rather than it's own path. - // Not sure of the ramifications of disttributing modified code. - ini_set('include_path', '.' . PATH_SEPARATOR . ABSPATH . WPINC ); - if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) ) require( ABSPATH . WPINC . '/wp-diff.php' ); @@ -1552,8 +1551,6 @@ function wp_text_diff( $left_string, $right_string, $args = null ) { $renderer = new WP_Text_Diff_Renderer_Table(); $diff = $renderer->render($text_diff); - ini_restore('include_path'); - if ( !$diff ) return ''; diff --git a/wp-settings.php b/wp-settings.php index 12a89bec12..474632a0d6 100644 --- a/wp-settings.php +++ b/wp-settings.php @@ -182,6 +182,20 @@ if ( defined('WP_CACHE') ) */ define('WPINC', 'wp-includes'); +if ( constant('WP_POST_REVISIONS') ) { + /* + * PEAR Text_Diff depends on the include path matching its directory + * structure. This prevents modifying source code and maintaining the + * modifications when the package is updated. + */ + if ( function_exists( 'set_include_path' ) ) + set_include_path( get_include_path() . PATH_SEPARATOR . ABSPATH . WPINC ); + else if ( function_exists( 'ini_set' ) ) + ini_set( 'include_path', ini_get('include_path') . PATH_SEPARATOR . ABSPATH . WPINC ); + else + define('WP_INCLUDE_PATH_DISABLED', true); +} + if ( !defined('WP_LANG_DIR') ) { /** * Stores the location of the language directory. First looks for language folder in WP_CONTENT_DIR