diff options
-rwxr-xr-x | ext/phar/phar_internal.h | 2 | ||||
-rwxr-xr-x | ext/phar/phar_object.c | 14 | ||||
-rw-r--r-- | ext/phar/tests/phar_oo_compressallbz2.phpt | 2 | ||||
-rw-r--r-- | ext/phar/tests/phar_oo_compressallgz.phpt | 2 | ||||
-rw-r--r-- | ext/phar/tests/phar_oo_getmodified.phpt | 2 | ||||
-rw-r--r-- | ext/phar/tests/phar_oo_uncompressall.phpt | 2 | ||||
-rw-r--r-- | ext/phar/tests/tar/tar_makebz2.phpt | 15 | ||||
-rw-r--r-- | ext/phar/tests/tar/tar_makegz.phpt | 15 | ||||
-rw-r--r-- | ext/phar/util.c | 12 |
9 files changed, 40 insertions, 26 deletions
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h index 54203114ac..0eac89ee35 100755 --- a/ext/phar/phar_internal.h +++ b/ext/phar/phar_internal.h @@ -376,7 +376,7 @@ char *phar_create_default_stub(const char *index_php, const char *web_index, siz char * phar_decompress_filter(phar_entry_info * entry, int return_unknown); char * phar_compress_filter(phar_entry_info * entry, int return_unknown); -void phar_rename_archive(phar_archive_data *phar, char *ext TSRMLS_DC); +void phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool compress TSRMLS_DC); int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len, char *path, int path_len TSRMLS_DC); char *phar_find_in_include_path(char *file, char *entry, phar_archive_data *phar TSRMLS_DC); char *phar_fix_filepath(char *path, int *new_len, int use_cwd TSRMLS_DC); diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index bc1aada584..c143e447f6 100755 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -1734,7 +1734,7 @@ static void phar_convert_to_other(phar_archive_data *source, int convert, char * source->is_temporary_alias = 0; source->flags = phar.flags; - phar_rename_archive(source, ext TSRMLS_CC); + phar_rename_archive(source, ext, 0 TSRMLS_CC); phar_flush(source, 0, 0, convert, &error TSRMLS_CC); } /* }}} */ @@ -2432,8 +2432,10 @@ PHP_METHOD(Phar, compressAllFilesGZ) } else { pharobj_set_compression(&phar_obj->arc.archive->manifest, PHAR_ENT_COMPRESSED_GZ TSRMLS_CC); } + phar_obj->arc.archive->is_modified = 1; - + phar_rename_archive(phar_obj->arc.archive, NULL, 1 TSRMLS_CC); + phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC); if (error) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, error); @@ -2471,8 +2473,10 @@ PHP_METHOD(Phar, compressAllFilesBZIP2) } else { pharobj_set_compression(&phar_obj->arc.archive->manifest, PHAR_ENT_COMPRESSED_BZ2 TSRMLS_CC); } + phar_obj->arc.archive->is_modified = 1; - + phar_rename_archive(phar_obj->arc.archive, NULL, 1 TSRMLS_CC); + phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC); if (error) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, error); @@ -2504,8 +2508,10 @@ PHP_METHOD(Phar, uncompressAllFiles) } else { pharobj_set_compression(&phar_obj->arc.archive->manifest, PHAR_ENT_COMPRESSED_NONE TSRMLS_CC); } + phar_obj->arc.archive->is_modified = 1; - + phar_rename_archive(phar_obj->arc.archive, NULL, 0 TSRMLS_CC); + phar_flush(phar_obj->arc.archive, 0, 0, 0, &error TSRMLS_CC); if (error) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, error); diff --git a/ext/phar/tests/phar_oo_compressallbz2.phpt b/ext/phar/tests/phar_oo_compressallbz2.phpt index 40720ef174..7120f6411d 100644 --- a/ext/phar/tests/phar_oo_compressallbz2.phpt +++ b/ext/phar/tests/phar_oo_compressallbz2.phpt @@ -44,7 +44,7 @@ var_dump($phar['b']->isCompressedBZIP2()); ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?> --EXPECTF-- string(1) "a" diff --git a/ext/phar/tests/phar_oo_compressallgz.phpt b/ext/phar/tests/phar_oo_compressallgz.phpt index 4a67bf64ed..71274491f1 100644 --- a/ext/phar/tests/phar_oo_compressallgz.phpt +++ b/ext/phar/tests/phar_oo_compressallgz.phpt @@ -44,7 +44,7 @@ var_dump($phar['b']->isCompressedBZIP2()); ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?> --EXPECTF-- string(1) "a" diff --git a/ext/phar/tests/phar_oo_getmodified.phpt b/ext/phar/tests/phar_oo_getmodified.phpt index 33cfc08e92..c537291631 100644 --- a/ext/phar/tests/phar_oo_getmodified.phpt +++ b/ext/phar/tests/phar_oo_getmodified.phpt @@ -27,7 +27,7 @@ var_dump($phar->getModified()); ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?> --EXPECTF-- bool(false) diff --git a/ext/phar/tests/phar_oo_uncompressall.phpt b/ext/phar/tests/phar_oo_uncompressall.phpt index d2f2ca5420..b447e96d02 100644 --- a/ext/phar/tests/phar_oo_uncompressall.phpt +++ b/ext/phar/tests/phar_oo_uncompressall.phpt @@ -52,7 +52,7 @@ var_dump($phar['a']->isCompressed()); ===DONE=== --CLEAN-- <?php -unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); +unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?> --EXPECTF-- string(1) "a" diff --git a/ext/phar/tests/tar/tar_makebz2.phpt b/ext/phar/tests/tar/tar_makebz2.phpt index 203265b385..f72670f7a1 100644 --- a/ext/phar/tests/tar/tar_makebz2.phpt +++ b/ext/phar/tests/tar/tar_makebz2.phpt @@ -10,18 +10,17 @@ phar.readonly=0 <?php $fname = dirname(__FILE__) . '/tar_makebz2.phar.tar'; -$alias = 'phar://' . $fname; -$fname2 = dirname(__FILE__) . '/tar_makebz2_b.phar.tar'; -$alias2 = 'phar://' . $fname2; +$fname2 = dirname(__FILE__) . '/tar_makebz2.phar.tar.bz2'; +$fname3 = dirname(__FILE__) . '/tar_makebz2_b.phar.tar.bz2'; $phar = new Phar($fname); $phar['test'] = 'hi'; var_dump($phar->isTar()); $phar->compressAllFilesBZIP2(); -copy($fname, $fname2); +copy($fname2, $fname3); -$phar2 = new Phar($fname2); +$phar2 = new Phar($fname3); var_dump($phar2->isTar()); var_dump($phar2->isCompressed() == Phar::BZ2); @@ -29,11 +28,11 @@ var_dump($phar2->isCompressed() == Phar::BZ2); ===DONE=== --CLEAN-- <?php -@unlink(dirname(__FILE__) . '/tar_makebz2.phar.tar'); -@unlink(dirname(__FILE__) . '/tar_makebz2_b.phar.tar'); +@unlink(dirname(__FILE__) . '/tar_makebz2.phar.tar.bz2'); +@unlink(dirname(__FILE__) . '/tar_makebz2_b.phar.tar.bz2'); ?> --EXPECTF-- bool(true) bool(true) bool(true) -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/phar/tests/tar/tar_makegz.phpt b/ext/phar/tests/tar/tar_makegz.phpt index 280c51a762..dada63de68 100644 --- a/ext/phar/tests/tar/tar_makegz.phpt +++ b/ext/phar/tests/tar/tar_makegz.phpt @@ -9,19 +9,18 @@ phar.readonly=0 --FILE-- <?php -$fname = dirname(__FILE__) . '/tar_makegz.phar.tar'; -$alias = 'phar://' . $fname; -$fname2 = dirname(__FILE__) . '/tar_makegz_b.phar.tar'; -$alias2 = 'phar://' . $fname2; +$fname = dirname(__FILE__) . '/tar_makebz2.phar.tar'; +$fname2 = dirname(__FILE__) . '/tar_makebz2.phar.tar.gz'; +$fname3 = dirname(__FILE__) . '/tar_makebz2_b.phar.tar.gz'; $phar = new Phar($fname); $phar['test'] = 'hi'; var_dump($phar->isTar()); $phar->compressAllFilesGZ(); -copy($fname, $fname2); +copy($fname2, $fname3); -$phar2 = new Phar($fname2); +$phar2 = new Phar($fname3); var_dump($phar2->isTar()); var_dump($phar2->isCompressed() == Phar::GZ); @@ -29,8 +28,8 @@ var_dump($phar2->isCompressed() == Phar::GZ); ===DONE=== --CLEAN-- <?php -@unlink(dirname(__FILE__) . '/tar_makegz.phar.tar'); -@unlink(dirname(__FILE__) . '/tar_makegz_b.phar.tar'); +@unlink(dirname(__FILE__) . '/tar_makebz2.phar.tar.gz'); +@unlink(dirname(__FILE__) . '/tar_makebz2_b.phar.tar.gz'); ?> --EXPECTF-- bool(true) diff --git a/ext/phar/util.c b/ext/phar/util.c index 5eee45b511..36e77184f1 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -72,12 +72,22 @@ int phar_seek_efp(phar_entry_info *entry, off_t offset, int whence, off_t positi return php_stream_seek(fp, temp, SEEK_SET); } -void phar_rename_archive(phar_archive_data *phar, char *ext TSRMLS_DC) +void phar_rename_archive(phar_archive_data *phar, char *ext, zend_bool compress TSRMLS_DC) { char *oldname = NULL, *oldpath = NULL; char *basename = NULL, *basepath = NULL; char *newname = NULL, *newpath = NULL; + if (phar->flags && compress) { + char *error; + + phar_flush(phar, 0, 0, 0, &error TSRMLS_CC); + if (error) { + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, error); + efree(error); + } + } + if (!ext) { if (phar->is_zip) { if (phar->is_data) { |