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
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
// $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);
}
#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
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);
}
}
break;
case PHAR_ENT_COMPRESSED_BZ2:
- if (!phar_has_bz2) {
+ if (!PHAR_G(has_bz2)) {
if (entry.metadata) {
zval_ptr_dtor(&entry.metadata);
}
/* 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);
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 */
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;
{
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;
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);
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)");
*/
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
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;
#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
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;
{
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);
}
}
"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;
"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;
"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;
"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;
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;
}
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;
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;
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;
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;
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;
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;
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;
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;
"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;
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");
}