From d748f8b7f1e123091d6c779f330d00794128f71c Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 20 Apr 2011 23:33:28 +0000 Subject: [PATCH] Tweak wfDl() so it actually works properly in 5.3.x Also add $fileName parameter in case the extension doesn't match the filename Minor tweak for windows, its files begin php_ --- includes/GlobalFunctions.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 8460c8aec1..e93cc02dbf 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -2282,19 +2282,30 @@ function wfIniGetBool( $setting ) { * * @param $extension String A PHP extension. The file suffix (.so or .dll) * should be omitted + * @param $fileName String Name of the library, if not $extension.suffix * @return Bool - Whether or not the extension is loaded */ -function wfDl( $extension ) { +function wfDl( $extension, $fileName = null ) { if( extension_loaded( $extension ) ) { return true; } - $canDl = ( function_exists( 'dl' ) && is_callable( 'dl' ) + $canDl = false; + $sapi = php_sapi_name(); + if( version_compare( PHP_VERSION, '5.3.0', '<' ) || + $sapi == 'cli' || $sapi == 'cgi' || $sapi == 'embed' ) + { + $canDl = ( function_exists( 'dl' ) && is_callable( 'dl' ) && wfIniGetBool( 'enable_dl' ) && !wfIniGetBool( 'safe_mode' ) ); + } if( $canDl ) { + $fileName = $fileName ? $fileName : $extension; + if( wfIsWindows() ) { + $fileName = 'php_' . $fileName; + } wfSuppressWarnings(); - dl( $extension . '.' . PHP_SHLIB_SUFFIX ); + dl( $fileName . '.' . PHP_SHLIB_SUFFIX ); wfRestoreWarnings(); } return extension_loaded( $extension ); -- 2.20.1