Browse Source

new pear, 5.3 bug fix

Paweł Bukowski 10 years ago
parent
commit
0344fde5c9
2 changed files with 99 additions and 47 deletions
  1. 98
    46
      PEAR.php
  2. 1
    1
      include/database.php

+ 98
- 46
PEAR.php View File

@@ -6,21 +6,15 @@
6 6
  *
7 7
  * PHP versions 4 and 5
8 8
  *
9
- * LICENSE: This source file is subject to version 3.0 of the PHP license
10
- * that is available through the world-wide-web at the following URI:
11
- * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
12
- * the PHP License and are unable to obtain it through the web, please
13
- * send a note to license@php.net so we can mail you a copy immediately.
14
- *
15 9
  * @category   pear
16 10
  * @package    PEAR
17 11
  * @author     Sterling Hughes <sterling@php.net>
18 12
  * @author     Stig Bakken <ssb@php.net>
19 13
  * @author     Tomas V.V.Cox <cox@idecnet.com>
20 14
  * @author     Greg Beaver <cellog@php.net>
21
- * @copyright  1997-2006 The PHP Group
22
- * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
23
- * @version    CVS: $Id: PEAR.php,v 1.101 2006/04/25 02:41:03 cellog Exp $
15
+ * @copyright  1997-2009 The Authors
16
+ * @license    http://opensource.org/licenses/bsd-license.php New BSD License
17
+ * @version    CVS: $Id: PEAR.php,v 1.111 2009/04/08 23:32:04 dufuz Exp $
24 18
  * @link       http://pear.php.net/package/PEAR
25 19
  * @since      File available since Release 0.1
26 20
  */
@@ -52,15 +46,6 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
52 46
     define('PEAR_OS',    'Unix'); // blatant assumption
53 47
 }
54 48
 
55
-// instant backwards compatibility
56
-if (!defined('PATH_SEPARATOR')) {
57
-    if (OS_WINDOWS) {
58
-        define('PATH_SEPARATOR', ';');
59
-    } else {
60
-        define('PATH_SEPARATOR', ':');
61
-    }
62
-}
63
-
64 49
 $GLOBALS['_PEAR_default_error_mode']     = PEAR_ERROR_RETURN;
65 50
 $GLOBALS['_PEAR_default_error_options']  = E_USER_NOTICE;
66 51
 $GLOBALS['_PEAR_destructor_object_list'] = array();
@@ -92,8 +77,8 @@ $GLOBALS['_PEAR_error_handler_stack']    = array();
92 77
  * @author     Tomas V.V. Cox <cox@idecnet.com>
93 78
  * @author     Greg Beaver <cellog@php.net>
94 79
  * @copyright  1997-2006 The PHP Group
95
- * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
96
- * @version    Release: 1.6.2
80
+ * @license    http://opensource.org/licenses/bsd-license.php New BSD License
81
+ * @version    Release: 1.8.0
97 82
  * @link       http://pear.php.net/package/PEAR
98 83
  * @see        PEAR_Error
99 84
  * @since      Class available since PHP 4.0.2
@@ -233,9 +218,11 @@ class PEAR
233 218
         if (!isset($properties[$class])) {
234 219
             $properties[$class] = array();
235 220
         }
221
+
236 222
         if (!array_key_exists($var, $properties[$class])) {
237 223
             $properties[$class][$var] = null;
238 224
         }
225
+
239 226
         return $properties[$class][$var];
240 227
     }
241 228
 
@@ -278,16 +265,17 @@ class PEAR
278 265
      */
279 266
     function isError($data, $code = null)
280 267
     {
281
-        if (is_a($data, 'PEAR_Error')) {
282
-            if (is_null($code)) {
283
-                return true;
284
-            } elseif (is_string($code)) {
285
-                return $data->getMessage() == $code;
286
-            } else {
287
-                return $data->getCode() == $code;
288
-            }
268
+        if (!is_a($data, 'PEAR_Error')) {
269
+            return false;
289 270
         }
290
-        return false;
271
+
272
+        if (is_null($code)) {
273
+            return true;
274
+        } elseif (is_string($code)) {
275
+            return $data->getMessage() == $code;
276
+        }
277
+
278
+        return $data->getCode() == $code;
291 279
     }
292 280
 
293 281
     // }}}
@@ -455,7 +443,6 @@ class PEAR
455 443
     function delExpect($error_code)
456 444
     {
457 445
         $deleted = false;
458
-
459 446
         if ((is_array($error_code) && (0 != count($error_code)))) {
460 447
             // $error_code is a non-empty array here;
461 448
             // we walk through it trying to unset all
@@ -475,10 +462,10 @@ class PEAR
475 462
             } else {
476 463
                 return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
477 464
             }
478
-        } else {
479
-            // $error_code is empty
480
-            return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
481 465
         }
466
+
467
+        // $error_code is empty
468
+        return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
482 469
     }
483 470
 
484 471
     // }}}
@@ -545,6 +532,7 @@ class PEAR
545 532
                 $mode = PEAR_ERROR_RETURN;
546 533
             }
547 534
         }
535
+
548 536
         // No mode given, try global ones
549 537
         if ($mode === null) {
550 538
             // Class error handler
@@ -565,13 +553,20 @@ class PEAR
565 553
         } else {
566 554
             $ec = 'PEAR_Error';
567 555
         }
568
-        if ($skipmsg) {
569
-            $a = &new $ec($code, $mode, $options, $userinfo);
556
+
557
+        if (intval(PHP_VERSION) < 5) {
558
+            // little non-eval hack to fix bug #12147
559
+            include 'PEAR/FixPHP5PEARWarnings.php';
570 560
             return $a;
561
+        }
562
+
563
+        if ($skipmsg) {
564
+            $a = new $ec($code, $mode, $options, $userinfo);
571 565
         } else {
572
-            $a = &new $ec($message, $code, $mode, $options, $userinfo);
573
-            return $a;
566
+            $a = new $ec($message, $code, $mode, $options, $userinfo);
574 567
         }
568
+
569
+        return $a;
575 570
     }
576 571
 
577 572
     // }}}
@@ -591,10 +586,10 @@ class PEAR
591 586
         if (isset($this) && is_a($this, 'PEAR')) {
592 587
             $a = &$this->raiseError($message, $code, null, null, $userinfo);
593 588
             return $a;
594
-        } else {
595
-            $a = &PEAR::raiseError($message, $code, null, null, $userinfo);
596
-            return $a;
597 589
         }
590
+
591
+        $a = &PEAR::raiseError($message, $code, null, null, $userinfo);
592
+        return $a;
598 593
     }
599 594
 
600 595
     // }}}
@@ -745,6 +740,7 @@ class PEAR
745 740
             if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
746 741
                 return false;
747 742
             }
743
+
748 744
             if (OS_WINDOWS) {
749 745
                 $suffix = '.dll';
750 746
             } elseif (PHP_OS == 'HP-UX') {
@@ -756,14 +752,51 @@ class PEAR
756 752
             } else {
757 753
                 $suffix = '.so';
758 754
             }
755
+
759 756
             return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
760 757
         }
758
+
761 759
         return true;
762 760
     }
763 761
 
764 762
     // }}}
765 763
 }
766 764
 
765
+if (PEAR_ZE2) {
766
+    /**
767
+     * This is only meant for PHP 5 to get rid of certain strict warning
768
+     * that doesn't get hidden since it's in the shutdown function
769
+     */
770
+    class PEAR5
771
+    {
772
+        /**
773
+        * If you have a class that's mostly/entirely static, and you need static
774
+        * properties, you can use this method to simulate them. Eg. in your method(s)
775
+        * do this: $myVar = &PEAR5::getStaticProperty('myclass', 'myVar');
776
+        * You MUST use a reference, or they will not persist!
777
+        *
778
+        * @access public
779
+        * @param  string $class  The calling classname, to prevent clashes
780
+        * @param  string $var    The variable to retrieve.
781
+        * @return mixed   A reference to the variable. If not set it will be
782
+        *                 auto initialised to NULL.
783
+        */
784
+        static function &getStaticProperty($class, $var)
785
+        {
786
+            static $properties;
787
+            if (!isset($properties[$class])) {
788
+                $properties[$class] = array();
789
+            }
790
+
791
+            if (!array_key_exists($var, $properties[$class])) {
792
+                $properties[$class][$var] = null;
793
+            }
794
+
795
+            return $properties[$class][$var];
796
+        }
797
+    }
798
+}
799
+
767 800
 // {{{ _PEAR_call_destructors()
768 801
 
769 802
 function _PEAR_call_destructors()
@@ -773,9 +806,16 @@ function _PEAR_call_destructors()
773 806
         sizeof($_PEAR_destructor_object_list))
774 807
     {
775 808
         reset($_PEAR_destructor_object_list);
776
-        if (PEAR::getStaticProperty('PEAR', 'destructlifo')) {
809
+        if (PEAR_ZE2) {
810
+            $destructLifoExists = PEAR5::getStaticProperty('PEAR', 'destructlifo');
811
+        } else {
812
+            $destructLifoExists = PEAR::getStaticProperty('PEAR', 'destructlifo');
813
+        }
814
+
815
+        if ($destructLifoExists) {
777 816
             $_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
778 817
         }
818
+
779 819
         while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
780 820
             $classname = get_class($objref);
781 821
             while ($classname) {
@@ -813,8 +853,8 @@ function _PEAR_call_destructors()
813 853
  * @author     Tomas V.V. Cox <cox@idecnet.com>
814 854
  * @author     Gregory Beaver <cellog@php.net>
815 855
  * @copyright  1997-2006 The PHP Group
816
- * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
817
- * @version    Release: 1.6.2
856
+ * @license    http://opensource.org/licenses/bsd-license.php New BSD License
857
+ * @version    Release: 1.8.0
818 858
  * @link       http://pear.php.net/manual/en/core.pear.pear-error.php
819 859
  * @see        PEAR::raiseError(), PEAR::throwError()
820 860
  * @since      Class available since PHP 4.0.2
@@ -864,7 +904,14 @@ class PEAR_Error
864 904
         $this->code      = $code;
865 905
         $this->mode      = $mode;
866 906
         $this->userinfo  = $userinfo;
867
-        if (!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) {
907
+
908
+        if (PEAR_ZE2) {
909
+            $skiptrace = PEAR5::getStaticProperty('PEAR_Error', 'skiptrace');
910
+        } else {
911
+            $skiptrace = PEAR::getStaticProperty('PEAR_Error', 'skiptrace');
912
+        }
913
+
914
+        if (!$skiptrace) {
868 915
             $this->backtrace = debug_backtrace();
869 916
             if (isset($this->backtrace[0]) && isset($this->backtrace[0]['object'])) {
870 917
                 unset($this->backtrace[0]['object']);
@@ -1048,6 +1095,12 @@ class PEAR_Error
1048 1095
 
1049 1096
     // }}}
1050 1097
     // {{{ toString()
1098
+    function __toString()
1099
+    {
1100
+        return $this->getMessage();
1101
+    }
1102
+    // }}}
1103
+    // {{{ toString()
1051 1104
 
1052 1105
     /**
1053 1106
      * Make a string representation of this object.
@@ -1104,5 +1157,4 @@ class PEAR_Error
1104 1157
  * tab-width: 4
1105 1158
  * c-basic-offset: 4
1106 1159
  * End:
1107
- */
1108
-?>
1160
+ */

+ 1
- 1
include/database.php View File

@@ -905,6 +905,6 @@ return $ret;
905 905
 
906 906
 }
907 907
 
908
-set_magic_quotes_runtime(false);
908
+@set_magic_quotes_runtime(false);
909 909
 DB::connect();
910 910
 ?>

Loading…
Cancel
Save