From: Greg Beaver Date: Sat, 17 May 2008 20:07:22 +0000 (+0000) Subject: enable by default statically instead of shared X-Git-Tag: BEFORE_NEW_PARAMETER_PARSE~203 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4aa4f1fabbdf4273786a9373bfae35a8b2945fd8;p=php 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 --- diff --git a/ext/phar/config.m4 b/ext/phar/config.m4 index e1009d39d5..e7a577d6a8 100644 --- a/ext/phar/config.m4 +++ b/ext/phar/config.m4 @@ -2,14 +2,12 @@ dnl $Id$ dnl config.m4 for extension phar PHP_ARG_ENABLE(phar, for phar archive support, -[ --disable-phar Disable phar support], shared) +[ --disable-phar Disable phar support], yes) 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 211443c452..f612f0dd13 100644 --- a/ext/phar/config.w32 +++ b/ext/phar/config.w32 @@ -1,14 +1,12 @@ // $Id$ // vim:ft=javascript -ARG_ENABLE("phar", "disable phar support", "shared"); +ARG_ENABLE("phar", "disable phar support", "yes"); if (PHP_PHAR != "no") { EXTENSION("phar", "dirstream.c func_interceptors.c phar.c phar_object.c phar_path_check.c stream.c tar.c util.c zip.c"); 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 8fffa99407..ea8863931e 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"); }