From d74b06f8c3d53ccdd39929ae37db8dc261b2ba77 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Sat, 31 Dec 2005 02:53:35 +0000 Subject: [PATCH] * Two new functions, wfUsePHP() and wfUseMW() which work like "use VERSION" in Perl for PHP and MediaWiki, respectively --- includes/GlobalFunctions.php | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) 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" ); +} + ?> -- 2.20.1