diff --git a/ext/phar/phar.c b/ext/phar/phar.c index d2fc3d6d4e2..c255bdb3b42 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -213,6 +213,13 @@ int phar_archive_delref(phar_archive_data *phar TSRMLS_DC) /* {{{ */ phar_destroy_phar_data(phar TSRMLS_CC); } return 1; + } else if (!phar->refcount) { + if (phar->fp) { + /* close open file handle - allows removal or rename of + the file on windows, which has greedy locking */ + php_stream_close(phar->fp); + phar->fp = NULL; + } } return 0; } diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 27c95cc4524..2493ee154aa 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1172,16 +1172,6 @@ PHP_METHOD(Phar, getSupportedCompression) return; \ } -/* {{{ proto void Phar::__destruct() - * remove reference count of phar - */ -PHP_METHOD(Phar, __destruct) -{ - PHAR_ARCHIVE_OBJECT(); - - phar_archive_delref(phar_obj->arc.archive TSRMLS_CC); -} - static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ */ { zval **value; @@ -3449,7 +3439,6 @@ zend_function_entry php_archive_methods[] = { PHP_ME(Phar, __construct, arginfo_phar___construct, ZEND_ACC_PRIVATE) #else PHP_ME(Phar, __construct, arginfo_phar___construct, ZEND_ACC_PUBLIC) - PHP_ME(Phar, __destruct, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phar, startBuffering, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phar, stopBuffering, NULL, ZEND_ACC_PUBLIC) PHP_ME(Phar, compressAllFilesGZ, NULL, ZEND_ACC_PUBLIC)