From: Platonides Date: Sat, 26 Feb 2011 22:37:58 +0000 (+0000) Subject: Move the include_path finding code to Fallback class. X-Git-Tag: 1.31.0-rc.0~31747 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=ab3f4cf4b3cf23b2a915d1463e175abf8282b126;p=lhc%2Fweb%2Fwiklou.git Move the include_path finding code to Fallback class. Checking availability when calling, as only UserMailer uses it. --- diff --git a/includes/Fallback.php b/includes/Fallback.php index 06dc9e79b0..c5f7c28613 100644 --- a/includes/Fallback.php +++ b/includes/Fallback.php @@ -173,5 +173,22 @@ class Fallback { return false; } } + + /** + * Fallback implementation of stream_resolve_include_path() + * Native stream_resolve_include_path is available for PHP 5 >= 5.3.2 + * @param $filename String + * @return String + */ + public static function stream_resolve_include_path( $filename ) { + $pathArray = explode( PATH_SEPARATOR, get_include_path() ); + foreach ( $pathArray as $path ) { + $fullFilename = $path . DIRECTORY_SEPARATOR . $filename; + if ( file_exists( $fullFilename ) ) { + return $fullFilename; + } + } + return false; + } -} \ No newline at end of file +} diff --git a/includes/UserMailer.php b/includes/UserMailer.php index 17fd74cf33..6b28c642aa 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -127,12 +127,10 @@ class UserMailer { if ( is_array( $wgSMTP ) ) { $found = false; - $pathArray = explode( PATH_SEPARATOR, get_include_path() ); - foreach ( $pathArray as $path ) { - if ( file_exists( $path . DIRECTORY_SEPARATOR . 'Mail.php' ) ) { - $found = true; - break; - } + if ( function_exists( 'stream_resolve_include_path' ) ) { + $found = stream_resolve_include_path( 'Mail.php' ); + } else { + $found = Fallback::stream_resolve_include_path( 'Mail.php' ); } if ( !$found ) { throw new MWException( 'PEAR mail package is not installed' );