if test "$PHP_PHAR" != "no"; then
PHP_NEW_EXTENSION(phar, phar.c phar_object.c phar_path_check.c, $ext_shared)
PHP_ADD_EXTENSION_DEP(phar, zlib, true)
- PHP_ADD_EXTENSION_DEP(phar, bz2, true)
+ PHP_ADD_EXTENSION_DEP(phar, bz2, false)
PHP_ADD_EXTENSION_DEP(phar, spl, false)
PHP_ADD_MAKEFILE_FRAGMENT
fi
}
efree(entry.filename);
MAPPHAR_FAIL("bz2 extension is required for bzip2 compressed .phar file \"%s\"");
+#else
+ if (!zend_hash_exists(&module_registry, "bz2", sizeof("bz2"))) {
+ MAPPHAR_FAIL("bz2 extension is required for bzip2 compressed .phar file \"%s\"");
+ }
#endif
break;
default:
#else
"disabled");
#endif
- php_info_print_table_row(2, "bzip2 compression",
#if HAVE_BZ2
- "enabled");
+ if (!zend_hash_exists(&module_registry, "bz2", sizeof("bz2"))) {
+ php_info_print_table_row(2, "bzip2 compression",
+ "disabled");
+ } else {
+ php_info_print_table_row(2, "bzip2 compression",
+ "enabled");
+ }
#else
+ php_info_print_table_row(2, "bzip2 compression",
"disabled");
#endif
php_info_print_table_end();
ZEND_MOD_REQUIRED("zlib")
#endif
#if HAVE_BZ2
- ZEND_MOD_REQUIRED("bz2")
+ ZEND_MOD_OPTIONAL("bz2")
#endif
#if HAVE_SPL
ZEND_MOD_REQUIRED("spl")
case PHAR_ENT_COMPRESSED_BZ2:
#if HAVE_BZ2
+ if (zend_hash_exists(&module_registry, "bz2", sizeof("bz2"))) {
RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
#else
RETURN_FALSE;
#endif
default:
#if HAVE_ZLIB || HAVE_BZ2
+ if (zend_hash_exists(&module_registry, "bz2", sizeof("bz2")) || HAVE_ZLIB) {
RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
#else
RETURN_FALSE;
#endif
add_next_index_stringl(return_value, "GZ", 2, 1);
#endif
#if !HAVE_BZ2
- add_next_index_stringl(return_value, "BZIP2", 5, 1);
+ if (zend_hash_exists(&module_registry, "bz2", sizeof("bz2"))) {
+ add_next_index_stringl(return_value, "BZIP2", 5, 1);
+ }
#endif
}
/* }}} */
return ZEND_HASH_APPLY_KEEP;
}
#if !HAVE_BZ2
- if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
- *(int *) argument = 0;
+ if (zend_hash_exists(&module_registry, "bz2", sizeof("bz2"))) {
+ if (entry->flags & PHAR_ENT_COMPRESSED_BZ2) {
+ *(int *) argument = 0;
+ }
}
#endif
#if !HAVE_ZLIB
"Phar is readonly, cannot change compression");
}
#if HAVE_BZ2
+ if (!zend_hash_exists(&module_registry, "bz2", sizeof("bz2"))) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress with Bzip2 compression, bz2 extension is not enabled");
+ }
if (!pharobj_cancompress(&phar_obj->arc.archive->manifest TSRMLS_CC)) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot compress all files as Bzip2, some are compressed as gzip and cannot be uncompressed");
char *error;
PHAR_ENTRY_OBJECT();
+ if (!zend_hash_exists(&module_registry, "bz2", sizeof("bz2"))) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot compress with Bzip2 compression, bz2 extension is not enabled");
+ }
if (entry_obj->ent.entry->is_dir) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, \
"Phar entry is a directory, cannot set compression"); \
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"Cannot uncompress Bzip2-compressed file, bzip2 extension is not enabled");
}
+#else
+ if (!zend_hash_exists(&module_registry, "bz2", sizeof("bz2"))) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
+ "Cannot uncompress Bzip2-compressed file, bzip2 extension is not enabled");
+ }
#endif
if (!entry_obj->ent.entry->fp) {
fname_len = spprintf(&fname, 0, "phar://%s/%s", entry_obj->ent.entry->phar->fname, entry_obj->ent.entry->filename);