Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, October 14, 2026

Diff for Metafox/lib/PEAR.php between version 1.7 and 1.8

version 1.7, 2015/11/24 17:21:06 version 1.8, 2017/06/09 15:05:06
Line 14 
Line 14 
  * @author     Greg Beaver <cellog@php.net>   * @author     Greg Beaver <cellog@php.net>
  * @copyright  1997-2010 The Authors   * @copyright  1997-2010 The Authors
  * @license    http://opensource.org/licenses/bsd-license.php New BSD License   * @license    http://opensource.org/licenses/bsd-license.php New BSD License
  * @version    CVS: $Id$  
  * @link       http://pear.php.net/package/PEAR   * @link       http://pear.php.net/package/PEAR
  * @since      File available since Release 0.1   * @since      File available since Release 0.1
  */   */
Line 33  define('PEAR_ERROR_CALLBACK',  16);
Line 32  define('PEAR_ERROR_CALLBACK',  16);
  */   */
 define('PEAR_ERROR_EXCEPTION', 32);  define('PEAR_ERROR_EXCEPTION', 32);
 /**#@-*/  /**#@-*/
 define('PEAR_ZE2', (function_exists('version_compare') &&  
                     version_compare(zend_version(), "2-dev", "ge")));  
   
 if (substr(PHP_OS, 0, 3) == 'WIN') {  if (substr(PHP_OS, 0, 3) == 'WIN') {
     define('OS_WINDOWS', true);      define('OS_WINDOWS', true);
Line 78  $GLOBALS['_PEAR_error_handler_stack']
Line 75  $GLOBALS['_PEAR_error_handler_stack']
  * @author     Greg Beaver <cellog@php.net>   * @author     Greg Beaver <cellog@php.net>
  * @copyright  1997-2006 The PHP Group   * @copyright  1997-2006 The PHP Group
  * @license    http://opensource.org/licenses/bsd-license.php New BSD License   * @license    http://opensource.org/licenses/bsd-license.php New BSD License
  * @version    Release: 1.9.3   * @version    Release: 1.10.4
  * @link       http://pear.php.net/package/PEAR   * @link       http://pear.php.net/package/PEAR
  * @see        PEAR_Error   * @see        PEAR_Error
  * @since      Class available since PHP 4.0.2   * @since      Class available since PHP 4.0.2
Line 137  class PEAR
Line 134  class PEAR
     var $_expected_errors = array();      var $_expected_errors = array();
   
     /**      /**
        * List of methods that can be called both statically and non-statically.
        * @var array
        */
       protected static $bivalentMethods = array(
           'setErrorHandling' => true,
           'raiseError' => true,
           'throwError' => true,
           'pushErrorHandling' => true,
           'popErrorHandling' => true,
       );
   
       /**
      * Constructor.  Registers this object in       * Constructor.  Registers this object in
      * $_PEAR_destructor_object_list for destructor emulation if a       * $_PEAR_destructor_object_list for destructor emulation if a
      * destructor object exists.       * destructor object exists.
Line 146  class PEAR
Line 155  class PEAR
      * @access public       * @access public
      * @return void       * @return void
      */       */
     function PEAR($error_class = null)      function __construct($error_class = null)
     {      {
         $classname = strtolower(get_class($this));          $classname = strtolower(get_class($this));
         if ($this->_debug) {          if ($this->_debug) {
Line 161  class PEAR
Line 170  class PEAR
             $destructor = "_$classname";              $destructor = "_$classname";
             if (method_exists($this, $destructor)) {              if (method_exists($this, $destructor)) {
                 global $_PEAR_destructor_object_list;                  global $_PEAR_destructor_object_list;
                 $_PEAR_destructor_object_list[] = &$this;                  $_PEAR_destructor_object_list[] = $this;
                 if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {                  if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
                     register_shutdown_function("_PEAR_call_destructors");                      register_shutdown_function("_PEAR_call_destructors");
                     $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;                      $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
Line 174  class PEAR
Line 183  class PEAR
     }      }
   
     /**      /**
        * Only here for backwards compatibility.
        * E.g. Archive_Tar calls $this->PEAR() in its constructor.
        *
        * @param string $error_class Which class to use for error objects,
        *                            defaults to PEAR_Error.
        */
       public function PEAR($error_class = null)
       {
           self::__construct($error_class);
       }
   
       /**
      * Destructor (the emulated type of...).  Does nothing right now,       * Destructor (the emulated type of...).  Does nothing right now,
      * but is included for forward compatibility, so subclass       * but is included for forward compatibility, so subclass
      * destructors should always call it.       * destructors should always call it.
Line 190  class PEAR
Line 211  class PEAR
         }          }
     }      }
   
       public function __call($method, $arguments)
       {
           if (!isset(self::$bivalentMethods[$method])) {
               trigger_error(
                   'Call to undefined method PEAR::' . $method . '()', E_USER_ERROR
               );
           }
           return call_user_func_array(
               array(get_class(), '_' . $method),
               array_merge(array($this), $arguments)
           );
       }
   
       public static function __callStatic($method, $arguments)
       {
           if (!isset(self::$bivalentMethods[$method])) {
               trigger_error(
                   'Call to undefined method PEAR::' . $method . '()', E_USER_ERROR
               );
           }
           return call_user_func_array(
               array(get_class(), '_' . $method),
               array_merge(array(null), $arguments)
           );
       }
   
     /**      /**
     * If you have a class that's mostly/entirely static, and you need static      * If you have a class that's mostly/entirely static, and you need static
     * properties, you can use this method to simulate them. Eg. in your method(s)      * properties, you can use this method to simulate them. Eg. in your method(s)
     * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');      * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
     * You MUST use a reference, or they will not persist!      * You MUST use a reference, or they will not persist!
     *      *
     * @access public  
     * @param  string $class  The calling classname, to prevent clashes      * @param  string $class  The calling classname, to prevent clashes
     * @param  string $var    The variable to retrieve.      * @param  string $var    The variable to retrieve.
     * @return mixed   A reference to the variable. If not set it will be      * @return mixed   A reference to the variable. If not set it will be
     *                 auto initialised to NULL.      *                 auto initialised to NULL.
     */      */
     function &getStaticProperty($class, $var)      public static function &getStaticProperty($class, $var)
     {      {
         static $properties;          static $properties;
         if (!isset($properties[$class])) {          if (!isset($properties[$class])) {
Line 220  class PEAR
Line 266  class PEAR
     * Use this function to register a shutdown method for static      * Use this function to register a shutdown method for static
     * classes.      * classes.
     *      *
     * @access public  
     * @param  mixed $func  The function name (or array of class/method) to call      * @param  mixed $func  The function name (or array of class/method) to call
     * @param  mixed $args  The arguments to pass to the function      * @param  mixed $args  The arguments to pass to the function
       *
     * @return void      * @return void
     */      */
     function registerShutdownFunc($func, $args = array())      public static function registerShutdownFunc($func, $args = array())
     {      {
         // if we are called statically, there is a potential          // if we are called statically, there is a potential
         // that no shutdown func is registered.  Bug #6445          // that no shutdown func is registered.  Bug #6445
Line 244  class PEAR
Line 290  class PEAR
      *                        only if $code is a string and       *                        only if $code is a string and
      *                        $obj->getMessage() == $code or       *                        $obj->getMessage() == $code or
      *                        $code is an integer and $obj->getCode() == $code       *                        $code is an integer and $obj->getCode() == $code
      * @access  public       *
      * @return  bool    true if parameter is an error       * @return  bool    true if parameter is an error
      */       */
     static function isError($data, $code = null)      public static function isError($data, $code = null)
     {      {
         if (!is_a($data, 'PEAR_Error')) {          if (!is_a($data, 'PEAR_Error')) {
             return false;              return false;
Line 269  class PEAR
Line 315  class PEAR
      * PEAR objects.  If called in an object, setErrorHandling sets       * PEAR objects.  If called in an object, setErrorHandling sets
      * the default behaviour for that object.       * the default behaviour for that object.
      *       *
        * @param object $object
        *        Object the method was called on (non-static mode)
        *
      * @param int $mode       * @param int $mode
      *        One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,       *        One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
      *        PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,       *        PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
Line 300  class PEAR
Line 349  class PEAR
      *       *
      * @since PHP 4.0.5       * @since PHP 4.0.5
      */       */
     static function setErrorHandling($mode = null, $options = null)      protected static function _setErrorHandling(
     {          $object, $mode = null, $options = null
         if (isset($this) && is_a($this, 'PEAR')) {      ) {
             $setmode     = &$this->_default_error_mode;          if ($object !== null) {
             $setoptions  = &$this->_default_error_options;              $setmode     = &$object->_default_error_mode;
               $setoptions  = &$object->_default_error_options;
         } else {          } else {
             $setmode     = &$GLOBALS['_PEAR_default_error_mode'];              $setmode     = &$GLOBALS['_PEAR_default_error_mode'];
             $setoptions  = &$GLOBALS['_PEAR_default_error_options'];              $setoptions  = &$GLOBALS['_PEAR_default_error_options'];
Line 400  class PEAR
Line 450  class PEAR
     }      }
   
     /**      /**
      * This method deletes all occurences of the specified element from       * This method deletes all occurrences of the specified element from
      * the expected error codes stack.       * the expected error codes stack.
      *       *
      * @param  mixed $error_code error code that should be deleted       * @param  mixed $error_code error code that should be deleted
Line 464  class PEAR
Line 514  class PEAR
      * @param bool $skipmsg If true, raiseError will only pass error codes,       * @param bool $skipmsg If true, raiseError will only pass error codes,
      *                  the error message parameter will be dropped.       *                  the error message parameter will be dropped.
      *       *
      * @access public  
      * @return object   a PEAR error object       * @return object   a PEAR error object
      * @see PEAR::setErrorHandling       * @see PEAR::setErrorHandling
      * @since PHP 4.0.5       * @since PHP 4.0.5
      */       */
     function &raiseError($message = null,      protected static function _raiseError($object,
                            $message = null,
                          $code = null,                           $code = null,
                          $mode = null,                           $mode = null,
                          $options = null,                           $options = null,
Line 487  class PEAR
Line 537  class PEAR
         }          }
   
         if (          if (
             isset($this) &&              $object !== null &&
             isset($this->_expected_errors) &&              isset($object->_expected_errors) &&
             count($this->_expected_errors) > 0 &&              count($object->_expected_errors) > 0 &&
             count($exp = end($this->_expected_errors))              count($exp = end($object->_expected_errors))
         ) {          ) {
             if ($exp[0] == "*" ||              if ($exp[0] == "*" ||
                 (is_int(reset($exp)) && in_array($code, $exp)) ||                  (is_int(reset($exp)) && in_array($code, $exp)) ||
Line 503  class PEAR
Line 553  class PEAR
         // No mode given, try global ones          // No mode given, try global ones
         if ($mode === null) {          if ($mode === null) {
             // Class error handler              // Class error handler
             if (isset($this) && isset($this->_default_error_mode)) {              if ($object !== null && isset($object->_default_error_mode)) {
                 $mode    = $this->_default_error_mode;                  $mode    = $object->_default_error_mode;
                 $options = $this->_default_error_options;                  $options = $object->_default_error_options;
             // Global error handler              // Global error handler
             } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {              } elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
                 $mode    = $GLOBALS['_PEAR_default_error_mode'];                  $mode    = $GLOBALS['_PEAR_default_error_mode'];
Line 515  class PEAR
Line 565  class PEAR
   
         if ($error_class !== null) {          if ($error_class !== null) {
             $ec = $error_class;              $ec = $error_class;
         } elseif (isset($this) && isset($this->_error_class)) {          } elseif ($object !== null && isset($object->_error_class)) {
             $ec = $this->_error_class;              $ec = $object->_error_class;
         } else {          } else {
             $ec = 'PEAR_Error';              $ec = 'PEAR_Error';
         }          }
   
         if (intval(PHP_VERSION) < 5) {  
             // little non-eval hack to fix bug #12147  
             include 'PEAR/FixPHP5PEARWarnings.php';  
             return $a;  
         }  
   
         if ($skipmsg) {          if ($skipmsg) {
             $a = new $ec($code, $mode, $options, $userinfo);              $a = new $ec($code, $mode, $options, $userinfo);
         } else {          } else {
Line 548  class PEAR
Line 592  class PEAR
      * @param string $userinfo If you need to pass along for example debug       * @param string $userinfo If you need to pass along for example debug
      *                  information, this parameter is meant for that.       *                  information, this parameter is meant for that.
      *       *
      * @access public  
      * @return object   a PEAR error object       * @return object   a PEAR error object
      * @see PEAR::raiseError       * @see PEAR::raiseError
      */       */
     function &throwError($message = null, $code = null, $userinfo = null)      protected static function _throwError($object, $message = null, $code = null, $userinfo = null)
     {      {
         if (isset($this) && is_a($this, 'PEAR')) {          if ($object !== null) {
             $a = &$this->raiseError($message, $code, null, null, $userinfo);              $a = $object->raiseError($message, $code, null, null, $userinfo);
             return $a;              return $a;
         }          }
   
         $a = &PEAR::raiseError($message, $code, null, null, $userinfo);          $a = PEAR::raiseError($message, $code, null, null, $userinfo);
         return $a;          return $a;
     }      }
   
Line 598  class PEAR
Line 641  class PEAR
         return true;          return true;
     }      }
   
     function staticPopErrorHandling()      public static function staticPopErrorHandling()
     {      {
         $stack = &$GLOBALS['_PEAR_error_handler_stack'];          $stack = &$GLOBALS['_PEAR_error_handler_stack'];
         $setmode     = &$GLOBALS['_PEAR_default_error_mode'];          $setmode     = &$GLOBALS['_PEAR_default_error_mode'];
Line 646  class PEAR
Line 689  class PEAR
      *       *
      * @see PEAR::setErrorHandling       * @see PEAR::setErrorHandling
      */       */
     public static function pushErrorHandling($mode, $options = null)      protected static function _pushErrorHandling($object, $mode, $options = null)
     {      {
         $stack = &$GLOBALS['_PEAR_error_handler_stack'];          $stack = &$GLOBALS['_PEAR_error_handler_stack'];
         if (isset($this) && is_a($this, 'PEAR')) {          if ($object !== null) {
             $def_mode    = &$this->_default_error_mode;              $def_mode    = &$object->_default_error_mode;
             $def_options = &$this->_default_error_options;              $def_options = &$object->_default_error_options;
         } else {          } else {
             $def_mode    = &$GLOBALS['_PEAR_default_error_mode'];              $def_mode    = &$GLOBALS['_PEAR_default_error_mode'];
             $def_options = &$GLOBALS['_PEAR_default_error_options'];              $def_options = &$GLOBALS['_PEAR_default_error_options'];
         }          }
         $stack[] = array($def_mode, $def_options);          $stack[] = array($def_mode, $def_options);
   
         if (isset($this) && is_a($this, 'PEAR')) {          if ($object !== null) {
             $this->setErrorHandling($mode, $options);              $object->setErrorHandling($mode, $options);
         } else {          } else {
             PEAR::setErrorHandling($mode, $options);              PEAR::setErrorHandling($mode, $options);
         }          }
Line 674  class PEAR
Line 717  class PEAR
     *      *
     * @see PEAR::pushErrorHandling      * @see PEAR::pushErrorHandling
     */      */
     function popErrorHandling()      protected static function _popErrorHandling($object)
     {      {
         $stack = &$GLOBALS['_PEAR_error_handler_stack'];          $stack = &$GLOBALS['_PEAR_error_handler_stack'];
         array_pop($stack);          array_pop($stack);
         list($mode, $options) = $stack[sizeof($stack) - 1];          list($mode, $options) = $stack[sizeof($stack) - 1];
         array_pop($stack);          array_pop($stack);
         if (isset($this) && is_a($this, 'PEAR')) {          if ($object !== null) {
             $this->setErrorHandling($mode, $options);              $object->setErrorHandling($mode, $options);
         } else {          } else {
             PEAR::setErrorHandling($mode, $options);              PEAR::setErrorHandling($mode, $options);
         }          }
Line 689  class PEAR
Line 732  class PEAR
     }      }
   
     /**      /**
     * OS independant PHP extension load. Remember to take care      * OS independent PHP extension load. Remember to take care
     * on the correct extension name for case sensitive OSes.      * on the correct extension name for case sensitive OSes.
     *      *
     * @param string $ext The extension name      * @param string $ext The extension name
Line 704  class PEAR
Line 747  class PEAR
         // if either returns true dl() will produce a FATAL error, stop that          // if either returns true dl() will produce a FATAL error, stop that
         if (          if (
             function_exists('dl') === false ||              function_exists('dl') === false ||
             ini_get('enable_dl') != 1 ||              ini_get('enable_dl') != 1
             ini_get('safe_mode') == 1  
         ) {          ) {
             return false;              return false;
         }          }
Line 726  class PEAR
Line 768  class PEAR
     }      }
 }  }
   
 if (PEAR_ZE2) {  
     include_once 'PEAR5.php';  
 }  
   
 function _PEAR_call_destructors()  function _PEAR_call_destructors()
 {  {
     global $_PEAR_destructor_object_list;      global $_PEAR_destructor_object_list;
Line 737  function _PEAR_call_destructors()
Line 775  function _PEAR_call_destructors()
         sizeof($_PEAR_destructor_object_list))          sizeof($_PEAR_destructor_object_list))
     {      {
         reset($_PEAR_destructor_object_list);          reset($_PEAR_destructor_object_list);
         if (PEAR_ZE2) {  
             $destructLifoExists = PEAR5::getStaticProperty('PEAR', 'destructlifo');          $destructLifoExists = PEAR::getStaticProperty('PEAR', 'destructlifo');
         } else {  
             $destructLifoExists = PEAR::getStaticProperty('PEAR', 'destructlifo');  
         }  
   
         if ($destructLifoExists) {          if ($destructLifoExists) {
             $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);              $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
Line 788  function _PEAR_call_destructors()
Line 823  function _PEAR_call_destructors()
  * @author     Gregory Beaver <cellog@php.net>   * @author     Gregory Beaver <cellog@php.net>
  * @copyright  1997-2006 The PHP Group   * @copyright  1997-2006 The PHP Group
  * @license    http://opensource.org/licenses/bsd-license.php New BSD License   * @license    http://opensource.org/licenses/bsd-license.php New BSD License
  * @version    Release: 1.9.3   * @version    Release: 1.10.4
  * @link       http://pear.php.net/manual/en/core.pear.pear-error.php   * @link       http://pear.php.net/manual/en/core.pear.pear-error.php
  * @see        PEAR::raiseError(), PEAR::throwError()   * @see        PEAR::raiseError(), PEAR::throwError()
  * @since      Class available since PHP 4.0.2   * @since      Class available since PHP 4.0.2
Line 823  class PEAR_Error
Line 858  class PEAR_Error
      * @access public       * @access public
      *       *
      */       */
     function PEAR_Error($message = 'unknown error', $code = null,      function __construct($message = 'unknown error', $code = null,
                         $mode = null, $options = null, $userinfo = null)                          $mode = null, $options = null, $userinfo = null)
     {      {
         if ($mode === null) {          if ($mode === null) {
Line 834  class PEAR_Error
Line 869  class PEAR_Error
         $this->mode      = $mode;          $this->mode      = $mode;
         $this->userinfo  = $userinfo;          $this->userinfo  = $userinfo;
   
         if (PEAR_ZE2) {          $skiptrace = PEAR::getStaticProperty('PEAR_Error', 'skiptrace');
             $skiptrace = PEAR5::getStaticProperty('PEAR_Error', 'skiptrace');  
         } else {  
             $skiptrace = PEAR::getStaticProperty('PEAR_Error', 'skiptrace');  
         }  
   
         if (!$skiptrace) {          if (!$skiptrace) {
             $this->backtrace = debug_backtrace();              $this->backtrace = debug_backtrace();
Line 883  class PEAR_Error
Line 914  class PEAR_Error
             } else {              } else {
                 $format = $options;                  $format = $options;
             }              }
             die(sprintf($format, $msg));              printf($format, $msg);
               exit($code);
         }          }
   
         if ($this->mode & PEAR_ERROR_CALLBACK && is_callable($this->callback)) {          if ($this->mode & PEAR_ERROR_CALLBACK && is_callable($this->callback)) {
Line 897  class PEAR_Error
Line 929  class PEAR_Error
     }      }
   
     /**      /**
        * Only here for backwards compatibility.
        *
        * Class "Cache_Error" still uses it, among others.
        *
        * @param string $message  Message
        * @param int    $code     Error code
        * @param int    $mode     Error mode
        * @param mixed  $options  See __construct()
        * @param string $userinfo Additional user/debug info
        */
       public function PEAR_Error(
           $message = 'unknown error', $code = null, $mode = null,
           $options = null, $userinfo = null
       ) {
           self::__construct($message, $code, $mode, $options, $userinfo);
       }
   
       /**
      * Get the error mode from an error object.       * Get the error mode from an error object.
      *       *
      * @return int error mode       * @return int error mode

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top