]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blobdiff - includes/json/Services_JSON.php
MediaWiki 1.16.0
[autoinstalls/mediawiki.git] / includes / json / Services_JSON.php
similarity index 97%
rename from includes/api/ApiFormatJson_json.php
rename to includes/json/Services_JSON.php
index 8cb3606d23e33ecc88942d41f77115fa41cb809a..9423352052f1e4d1e9dc6a7b2eafbd67b8b52900 100644 (file)
@@ -50,7 +50,7 @@
 * @author Matt Knapp <mdknapp[at]gmail[dot]com>
 * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
 * @copyright 2005 Michal Migurski
-* @version CVS: $Id: ApiFormatJson_json.php 45765 2009-01-15 10:18:44Z catrope $
+* @version CVS: $Id: Services_JSON.php 65683 2010-04-30 05:56:15Z tstarling $
 * @license http://www.opensource.org/licenses/bsd-license.php
 * @see http://pear.php.net/pepr/pepr-proposal-show.php?id=198
 */
@@ -135,6 +135,19 @@ class Services_JSON
        {
                $this->use = $use;
        }
+       
+       private static $mHavePear = null;
+       /**
+        * Returns cached result of class_exists('pear'), to avoid calling AutoLoader numerous times
+        * in cases when PEAR is not present.
+        * @return boolean
+        */
+       private static function pearInstalled() {
+               if ( self::$mHavePear === null ) {
+                       self::$mHavePear = class_exists( 'pear' );
+               }
+               return self::$mHavePear;
+       }
 
        /**
         * convert a string from one UTF-16 char to one UTF-8 char
@@ -815,8 +828,9 @@ class Services_JSON
         */
        function isError($data, $code = null)
        {
-               if (class_exists('pear')) {
-                       return PEAR::isError($data, $code);
+               if ( self::pearInstalled() ) {
+                       //avoid some strict warnings on PEAR isError check (looks like http://pear.php.net/bugs/bug.php?id=9950 has been around for some time)
+                       return @PEAR::isError($data, $code);
                } elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
                                is_subclass_of($data, 'services_json_error'))) {
                        return true;