* Two new functions, wfUsePHP() and wfUseMW() which work like "use VERSION" in
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Sat, 31 Dec 2005 02:53:35 +0000 (02:53 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Sat, 31 Dec 2005 02:53:35 +0000 (02:53 +0000)
  Perl for PHP and MediaWiki, respectively

includes/GlobalFunctions.php

index f4eadbe..319f112 100644 (file)
@@ -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" );
+}
+
 ?>