]> ToastFreeware Gitweb - toast/cookiecaptcha.git/blobdiff - MathCaptcha.class.php
Follow-up to r86811 and r92013 - instead of using class_exists() or MWInit::classExis...
[toast/cookiecaptcha.git] / MathCaptcha.class.php
index 1875b2fbb5b269806612ad793497e02bc3a8bfe9..220df31da583932c19ff47b9566c1f2709e25dda 100644 (file)
@@ -39,11 +39,17 @@ class MathCaptcha extends SimpleCaptcha {
 
        /** Fetch the math */
        function fetchMath( $sum ) {
-               if ( class_exists( 'MathRenderer' ) ){
-                       $math = new MathRenderer( $sum );
-               } else {
+               // class_exists() unfortunately doesn't work with HipHop, and
+               // its replacement, MWInit::classExists(), wasn't added until
+               // MW 1.18, and is thus unusable here - so instead, we'll
+               // just duplicate the code of MWInit::classExists().
+               try {
+                       $r = new ReflectionClass( 'MathRenderer' );
+               } catch( ReflectionException $r ) {
                        throw new MWException( 'MathCaptcha requires the Math extension for MediaWiki versions 1.18 and above.' );
                }
+
+               $math = new MathRenderer( $sum );
                $math->setOutputMode( MW_MATH_PNG );
                $html = $math->render();
                return preg_replace( '/alt=".*?"/', '', $html );