http://www.mediawiki.org/wiki/Special:Code/MediaWiki/82869

Revision: 82869
Author:   platonides
Date:     2011-02-26 22:37:58 +0000 (Sat, 26 Feb 2011)
Log Message:
-----------
Move the include_path finding code to Fallback class.
Checking availability when calling, as only UserMailer uses it.

Modified Paths:
--------------
    trunk/phase3/includes/Fallback.php
    trunk/phase3/includes/UserMailer.php

Modified: trunk/phase3/includes/Fallback.php
===================================================================
--- trunk/phase3/includes/Fallback.php  2011-02-26 22:30:41 UTC (rev 82868)
+++ trunk/phase3/includes/Fallback.php  2011-02-26 22:37:58 UTC (rev 82869)
@@ -173,5 +173,22 @@
                        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
+}

Modified: trunk/phase3/includes/UserMailer.php
===================================================================
--- trunk/phase3/includes/UserMailer.php        2011-02-26 22:30:41 UTC (rev 
82868)
+++ trunk/phase3/includes/UserMailer.php        2011-02-26 22:37:58 UTC (rev 
82869)
@@ -127,12 +127,10 @@
 
                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' );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to