From: Stig Bakken Date: Fri, 29 Mar 2002 00:05:55 +0000 (+0000) Subject: * fix tempfile cleanup X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~987 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=adc0b5741e0621c2a2944272927c4dbe0dd40076;p=php * fix tempfile cleanup --- diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php index dfa081c5a1..efbaaac2a7 100644 --- a/pear/PEAR/Common.php +++ b/pear/PEAR/Common.php @@ -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; } // }}}