r86574 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86573‎ | r86574 | r86575 >
Date:23:33, 20 April 2011
Author:demon
Status:ok (Comments)
Tags:
Comment:
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_
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2282,19 +2282,30 @@
22832283 *
22842284 * @param $extension String A PHP extension. The file suffix (.so or .dll)
22852285 * should be omitted
 2286+ * @param $fileName String Name of the library, if not $extension.suffix
22862287 * @return Bool - Whether or not the extension is loaded
22872288 */
2288 -function wfDl( $extension ) {
 2289+function wfDl( $extension, $fileName = null ) {
22892290 if( extension_loaded( $extension ) ) {
22902291 return true;
22912292 }
22922293
2293 - $canDl = ( function_exists( 'dl' ) && is_callable( 'dl' )
 2294+ $canDl = false;
 2295+ $sapi = php_sapi_name();
 2296+ if( version_compare( PHP_VERSION, '5.3.0', '<' ) ||
 2297+ $sapi == 'cli' || $sapi == 'cgi' || $sapi == 'embed' )
 2298+ {
 2299+ $canDl = ( function_exists( 'dl' ) && is_callable( 'dl' )
22942300 && wfIniGetBool( 'enable_dl' ) && !wfIniGetBool( 'safe_mode' ) );
 2301+ }
22952302
22962303 if( $canDl ) {
 2304+ $fileName = $fileName ? $fileName : $extension;
 2305+ if( wfIsWindows() ) {
 2306+ $fileName = 'php_' . $fileName;
 2307+ }
22972308 wfSuppressWarnings();
2298 - dl( $extension . '.' . PHP_SHLIB_SUFFIX );
 2309+ dl( $fileName . '.' . PHP_SHLIB_SUFFIX );
22992310 wfRestoreWarnings();
23002311 }
23012312 return extension_loaded( $extension );

Comments

#Comment by Brion VIBBER (talk | contribs)   00:53, 15 June 2011

Looks good.

Status & tagging log