summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Beaver <cellog@php.net>2008-05-17 20:07:38 +0000
committerGreg Beaver <cellog@php.net>2008-05-17 20:07:38 +0000
commit11fb7561f057aa3fdb11c13f76356f83ed67f17f (patch)
tree6b5ca4796ab201e85d5149fe4eb6f8775215ea2e
parent1e4b63372110fe56bd012d07bc53ab2e4bc5311b (diff)
downloadphp-git-11fb7561f057aa3fdb11c13f76356f83ed67f17f.tar.gz
enable by default statically instead of shared
this is done by removing zlib/bz2 explicit dependencies because they are unnecessary we only ever use the stream filter, and the check for existence has been moved to runtime where it is after startup
-rw-r--r--ext/phar/config.m42
-rw-r--r--ext/phar/config.w322
-rw-r--r--ext/phar/phar.c21
-rwxr-xr-xext/phar/phar_internal.h4
-rwxr-xr-xext/phar/phar_object.c44
-rw-r--r--ext/phar/zip.c4
6 files changed, 36 insertions, 41 deletions
diff --git a/ext/phar/config.m4 b/ext/phar/config.m4
index d3e4d5a54f..78b4fa30c7 100644
--- a/ext/phar/config.m4
+++ b/ext/phar/config.m4
@@ -8,8 +8,6 @@ if test "$PHP_PHAR" != "no"; then
PHP_NEW_EXTENSION(phar, util.c tar.c zip.c stream.c func_interceptors.c dirstream.c phar.c phar_object.c phar_path_check.c, $ext_shared)
PHP_ADD_BUILD_DIR($ext_builddir/lib, 1)
PHP_SUBST(PHAR_SHARED_LIBADD)
- PHP_ADD_EXTENSION_DEP(phar, zlib, true)
- PHP_ADD_EXTENSION_DEP(phar, bz2, true)
PHP_ADD_EXTENSION_DEP(phar, spl, true)
PHP_ADD_MAKEFILE_FRAGMENT
fi
diff --git a/ext/phar/config.w32 b/ext/phar/config.w32
index 35127a7b13..cbc68ca2e5 100644
--- a/ext/phar/config.w32
+++ b/ext/phar/config.w32
@@ -8,7 +8,5 @@ if (PHP_PHAR != "no") {
if (PHP_PHAR_SHARED) {
ADD_FLAG("CFLAGS_PHAR", "/D COMPILE_DL_PHAR ");
}
- ADD_EXTENSION_DEP('phar', 'bz2', true);
ADD_EXTENSION_DEP('phar', 'spl', true);
- ADD_EXTENSION_DEP('phar', 'zlib', true);
}
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index 2ac7209f1c..54ee0cad34 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -25,8 +25,6 @@
#include "func_interceptors.h"
ZEND_DECLARE_MODULE_GLOBALS(phar)
-int phar_has_bz2;
-int phar_has_zlib;
#if PHP_VERSION_ID >= 50300
char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
#endif
@@ -886,7 +884,7 @@ int phar_open_file(php_stream *fp, char *fname, int fname_len, char *alias, int
offset += entry.compressed_filesize;
switch (entry.flags & PHAR_ENT_COMPRESSION_MASK) {
case PHAR_ENT_COMPRESSED_GZ:
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
if (entry.metadata) {
zval_ptr_dtor(&entry.metadata);
}
@@ -895,7 +893,7 @@ int phar_open_file(php_stream *fp, char *fname, int fname_len, char *alias, int
}
break;
case PHAR_ENT_COMPRESSED_BZ2:
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
if (entry.metadata) {
zval_ptr_dtor(&entry.metadata);
}
@@ -1307,7 +1305,7 @@ static int phar_open_fp(php_stream* fp, char *fname, int fname_len, char *alias,
/* to properly decompress, we have to tell zlib to look for a zlib or gzip header */
zval filterparams;
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\" to temporary file, enable zlib extension in php.ini")
}
array_init(&filterparams);
@@ -1358,7 +1356,7 @@ static int phar_open_fp(php_stream* fp, char *fname, int fname_len, char *alias,
php_stream_filter *filter;
php_stream *temp;
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\" to temporary file, enable bz2 extension in php.ini")
}
/* entire file is bzip-compressed, uncompress to temporary file */
@@ -2943,8 +2941,6 @@ PHP_MINIT_FUNCTION(phar) /* {{{ */
ZEND_INIT_MODULE_GLOBALS(phar, php_phar_init_globals_module, NULL);
REGISTER_INI_ENTRIES();
- phar_has_bz2 = zend_hash_exists(&module_registry, "bz2", sizeof("bz2"));
- phar_has_zlib = zend_hash_exists(&module_registry, "zlib", sizeof("zlib"));
phar_orig_compile_file = zend_compile_file;
zend_compile_file = phar_compile_file;
@@ -2981,6 +2977,8 @@ void phar_request_initialize(TSRMLS_D) /* {{{ */
{
if (!PHAR_GLOBALS->request_init)
{
+ PHAR_G(has_bz2) = zend_hash_exists(&module_registry, "bz2", sizeof("bz2"));
+ PHAR_G(has_zlib) = zend_hash_exists(&module_registry, "zlib", sizeof("zlib"));
PHAR_GLOBALS->request_init = 1;
PHAR_GLOBALS->request_ends = 0;
PHAR_GLOBALS->request_done = 0;
@@ -3022,6 +3020,7 @@ PHP_RSHUTDOWN_FUNCTION(phar) /* {{{ */
PHP_MINFO_FUNCTION(phar) /* {{{ */
{
+ phar_request_initialize(TSRMLS_C);
php_info_print_table_start();
php_info_print_table_header(2, "Phar: PHP Archive support", "enabled");
php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION);
@@ -3030,12 +3029,12 @@ PHP_MINFO_FUNCTION(phar) /* {{{ */
php_info_print_table_row(2, "Phar-based phar archives", "enabled");
php_info_print_table_row(2, "Tar-based phar archives", "enabled");
php_info_print_table_row(2, "ZIP-based phar archives", "enabled");
- if (phar_has_zlib) {
+ if (PHAR_G(has_zlib)) {
php_info_print_table_row(2, "gzip compression", "enabled");
} else {
php_info_print_table_row(2, "gzip compression", "disabled (install ext/zlib)");
}
- if (phar_has_bz2) {
+ if (PHAR_G(has_bz2)) {
php_info_print_table_row(2, "bzip2 compression", "enabled");
} else {
php_info_print_table_row(2, "bzip2 compression", "disabled (install pecl/bz2)");
@@ -3058,8 +3057,6 @@ PHP_MINFO_FUNCTION(phar) /* {{{ */
*/
static zend_module_dep phar_deps[] = {
ZEND_MOD_OPTIONAL("apc")
- ZEND_MOD_OPTIONAL("zlib")
- ZEND_MOD_OPTIONAL("bz2")
#if HAVE_SPL
ZEND_MOD_REQUIRED("spl")
#endif
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
index 51f885ea01..185b1e2ffe 100755
--- a/ext/phar/phar_internal.h
+++ b/ext/phar/phar_internal.h
@@ -137,6 +137,8 @@ ZEND_BEGIN_MODULE_GLOBALS(phar)
HashTable phar_alias_map;
HashTable phar_SERVER_mung_list;
int readonly;
+ int has_zlib;
+ int has_bz2;
zend_bool readonly_orig;
zend_bool require_hash_orig;
int request_init;
@@ -347,8 +349,6 @@ union _phar_entry_object {
#endif
#ifndef PHAR_MAIN
-extern int phar_has_bz2;
-extern int phar_has_zlib;
# if PHP_VERSION_ID >= 50300
extern char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
# endif
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index ac810d4c48..a215ed4448 100755
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -1012,23 +1012,24 @@ PHP_METHOD(Phar, canCompress)
return;
}
+ phar_request_initialize(TSRMLS_C);
switch (method) {
case PHAR_ENT_COMPRESSED_GZ:
- if (phar_has_zlib) {
+ if (PHAR_G(has_zlib)) {
RETURN_TRUE;
} else {
RETURN_FALSE;
}
case PHAR_ENT_COMPRESSED_BZ2:
- if (phar_has_bz2) {
+ if (PHAR_G(has_bz2)) {
RETURN_TRUE;
} else {
RETURN_FALSE;
}
default:
- if (phar_has_zlib || phar_has_bz2) {
+ if (PHAR_G(has_zlib) || PHAR_G(has_bz2)) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -1227,10 +1228,11 @@ PHP_METHOD(Phar, getSupportedCompression)
{
array_init(return_value);
- if (phar_has_zlib) {
+ phar_request_initialize(TSRMLS_C);
+ if (PHAR_G(has_zlib)) {
add_next_index_stringl(return_value, "GZ", 2, 1);
}
- if (phar_has_bz2) {
+ if (PHAR_G(has_bz2)) {
add_next_index_stringl(return_value, "BZIP2", 5, 1);
}
}
@@ -2108,7 +2110,7 @@ PHP_METHOD(Phar, convertToExecutable)
"Cannot compress entire archive with gzip, zip archives do not support whole-archive compression");
return;
}
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
return;
@@ -2122,7 +2124,7 @@ PHP_METHOD(Phar, convertToExecutable)
"Cannot compress entire archive with bz2, zip archives do not support whole-archive compression");
return;
}
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
return;
@@ -2206,7 +2208,7 @@ PHP_METHOD(Phar, convertToData)
"Cannot compress entire archive with gzip, zip archives do not support whole-archive compression");
return;
}
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
return;
@@ -2220,7 +2222,7 @@ PHP_METHOD(Phar, convertToData)
"Cannot compress entire archive with bz2, zip archives do not support whole-archive compression");
return;
}
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
return;
@@ -2746,12 +2748,12 @@ static int phar_test_compression(void *pDest, void *argument TSRMLS_DC) /* {{{ *
if (entry->is_deleted) {
return ZEND_HASH_APPLY_KEEP;
}
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
*(int *) argument = 0;
}
}
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
if (entry->flags & PHAR_ENT_COMPRESSED_GZ) {
*(int *) argument = 0;
}
@@ -2810,7 +2812,7 @@ PHP_METHOD(Phar, compress)
flags = PHAR_FILE_COMPRESSED_NONE;
break;
case PHAR_ENT_COMPRESSED_GZ:
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with gzip, enable ext/zlib in php.ini");
return;
@@ -2819,7 +2821,7 @@ PHP_METHOD(Phar, compress)
break;
case PHAR_ENT_COMPRESSED_BZ2:
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress entire archive with bz2, enable ext/bz2 in php.ini");
return;
@@ -2908,7 +2910,7 @@ PHP_METHOD(Phar, compressFiles)
switch (method) {
case PHAR_ENT_COMPRESSED_GZ:
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress files within archive with gzip, enable ext/zlib in php.ini");
return;
@@ -2917,7 +2919,7 @@ PHP_METHOD(Phar, compressFiles)
break;
case PHAR_ENT_COMPRESSED_BZ2:
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress files within archive with bz2, enable ext/bz2 in php.ini");
return;
@@ -4256,7 +4258,7 @@ PHP_METHOD(PharFileInfo, compress)
return;
}
if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0) {
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress with gzip compression, file is already compressed with bzip2 compression and bz2 extension is not enabled, cannot decompress");
return;
@@ -4269,7 +4271,7 @@ PHP_METHOD(PharFileInfo, compress)
return;
}
}
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress with gzip compression, zlib extension is not enabled");
return;
@@ -4284,7 +4286,7 @@ PHP_METHOD(PharFileInfo, compress)
return;
}
if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0) {
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress with bzip2 compression, file is already compressed with gzip compression and zlib extension is not enabled, cannot decompress");
return;
@@ -4297,7 +4299,7 @@ PHP_METHOD(PharFileInfo, compress)
return;
}
}
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress with bzip2 compression, bz2 extension is not enabled");
return;
@@ -4350,12 +4352,12 @@ PHP_METHOD(PharFileInfo, decompress)
"Cannot compress deleted file");
return;
}
- if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0 && !phar_has_zlib) {
+ if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_GZ) != 0 && !PHAR_G(has_zlib)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot decompress Gzip-compressed file, zlib extension is not enabled");
return;
}
- if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0 && !phar_has_bz2) {
+ if ((entry_obj->ent.entry->flags & PHAR_ENT_COMPRESSED_BZ2) != 0 && !PHAR_G(has_bz2)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot decompress Bzip2-compressed file, bz2 extension is not enabled");
return;
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
index 0261033ff9..d266b53dce 100644
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@ -326,14 +326,14 @@ foundit:
break;
case PHAR_ZIP_COMP_DEFLATE :
entry.flags |= PHAR_ENT_COMPRESSED_GZ;
- if (!phar_has_zlib) {
+ if (!PHAR_G(has_zlib)) {
efree(entry.filename);
PHAR_ZIP_FAIL("zlib extension is required");
}
break;
case PHAR_ZIP_COMP_BZIP2 :
entry.flags |= PHAR_ENT_COMPRESSED_BZ2;
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
efree(entry.filename);
PHAR_ZIP_FAIL("bzip2 extension is required");
}