From: Ævar Arnfjörð Bjarmason Date: Sat, 31 Dec 2005 02:53:35 +0000 (+0000) Subject: * Two new functions, wfUsePHP() and wfUseMW() which work like "use VERSION" in X-Git-Tag: 1.6.0~830 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/?a=commitdiff_plain;h=d74b06f8c3d53ccdd39929ae37db8dc261b2ba77;p=lhc%2Fweb%2Fwiklou.git * Two new functions, wfUsePHP() and wfUseMW() which work like "use VERSION" in Perl for PHP and MediaWiki, respectively --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index f4eadbebb5..319f1127c7 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1691,4 +1691,47 @@ function wfShellExec( $cmd ) return shell_exec( $cmd ); } +/** + * This function works like "use VERSION" in Perl, the program will die with a + * backtrace if the current version of PHP is less than the version provided + * + * This is useful for extensions which due to their nature are not kept in sync + * with releases, and might depend on other versions of PHP than the main code + * + * Note: PHP might die due to parsing errors in some cases before it ever + * manages to call this function, such is life + * + * @see perldoc -f use + * + * @param mixed $version The version to check, can be a string, an integer, or + * a float + */ +function wfUsePHP( $req_ver ) { + $php_ver = PHP_VERSION; + + if ( version_compare( $php_ver, (string)$req_ver, '<' ) ) + wfDebugDieBacktrace( "PHP $req_ver required--this is only $php_ver" ); +} + +/** + * This function works like "use VERSION" in Perl except it checks the version + * of MediaWiki, the program will die with a backtrace if the current version + * of MediaWiki is less than the version provided. + * + * This is useful for extensions which due to their nature are not kept in sync + * with releases + * + * @see perldoc -f use + * + * @param mixed $version The version to check, can be a string, an integer, or + * a float + */ + +function wfUseMW( $req_ver ) { + global $wgVersion; + + if ( version_compare( $wgVersion, (string)$req_ver, '<' ) ) + wfDebugDieBacktrace( "MediaWiki $req_ver required--this is only $wgVersion" ); +} + ?>