]> granicus.if.org Git - php/commitdiff
* fix tempfile cleanup
authorStig Bakken <ssb@php.net>
Fri, 29 Mar 2002 00:05:55 +0000 (00:05 +0000)
committerStig Bakken <ssb@php.net>
Fri, 29 Mar 2002 00:05:55 +0000 (00:05 +0000)
pear/PEAR/Common.php

index dfa081c5a1a77220a399d6e3e6bc6b96ccc2c919..efbaaac2a77b0921044db8dd405000eaa0110b7c 100644 (file)
@@ -23,6 +23,13 @@ require_once 'PEAR.php';
 require_once 'Archive/Tar.php';
 require_once 'System.php';
 
+/**
+ * List of temporary files and directories registered by
+ * PEAR_Common::addTempFile().
+ * @var array
+ */
+$GLOBALS['_PEAR_Common_tempfiles'] = array();
+
 /*
  * TODO:
  *   - check in inforFromDescFile that the minimal data needed is present
@@ -46,9 +53,6 @@ class PEAR_Common extends PEAR
     /** array of attributes of the currently parsed XML element */
     var $current_attributes = array();
 
-    /** list of temporary files created by this object */
-    var $_tempfiles = array();
-
     /** assoc with information about a package */
     var $pkginfo = array();
 
@@ -75,8 +79,6 @@ class PEAR_Common extends PEAR
      */
     function PEAR_Common()
     {
-        $GLOBALS['_PEAR_Common_tempfiles'] = array();
-        $this->_tempfiles =& $GLOBALS['_PEAR_Common_tempfiles'];
         $this->PEAR();
     }
 
@@ -93,9 +95,7 @@ class PEAR_Common extends PEAR
         // doesn't work due to bug #14744
         //$tempfiles = $this->_tempfiles;
         $tempfiles =& $GLOBALS['_PEAR_Common_tempfiles'];
-        while (is_array($tempfiles) &&
-               $file = array_shift($tempfiles))
-        {
+        while ($file = array_shift($tempfiles)) {
             if (@is_dir($file)) {
                 System::rm("-rf $file");
             } elseif (file_exists($file)) {
@@ -120,7 +120,7 @@ class PEAR_Common extends PEAR
      */
     function addTempFile($file)
     {
-        $this->_tempfiles[] = $file;
+        $GLOBALS['_PEAR_Common_tempfiles'][] = $file;
     }
 
     // }}}