summaryrefslogtreecommitdiff
path: root/ext/phar
diff options
context:
space:
mode:
Diffstat (limited to 'ext/phar')
-rw-r--r--ext/phar/Makefile.frag2
-rw-r--r--ext/phar/config.m42
-rw-r--r--ext/phar/dirstream.c10
-rw-r--r--ext/phar/phar.c98
-rw-r--r--ext/phar/phar_internal.h59
-rw-r--r--ext/phar/phar_object.c128
-rw-r--r--ext/phar/phar_path_check.c2
-rw-r--r--ext/phar/php_phar.h6
-rw-r--r--ext/phar/stream.c20
-rw-r--r--ext/phar/tests/create_new_and_modify.phpt8
-rw-r--r--ext/phar/tests/delete_in_phar.phpt9
-rw-r--r--ext/phar/tests/delete_in_phar_confirm.phpt9
-rw-r--r--ext/phar/tests/phar_commitwrite.phpt2
-rw-r--r--ext/phar/tests/phar_create_in_cwd.phpt2
-rw-r--r--ext/phar/tests/phar_gobyebye.phpt2
-rw-r--r--ext/phar/tests/phar_mount.phpt2
-rw-r--r--ext/phar/tests/phpinfo_001.phpt4
-rw-r--r--ext/phar/tests/phpinfo_002.phpt2
-rw-r--r--ext/phar/tests/phpinfo_004.phpt4
-rw-r--r--ext/phar/tests/tar/create_new_and_modify.phpt8
-rw-r--r--ext/phar/tests/tar/delete_in_phar.phpt8
-rw-r--r--ext/phar/tests/tar/delete_in_phar_confirm.phpt8
-rw-r--r--ext/phar/tests/zip/create_new_and_modify.phpt8
-rw-r--r--ext/phar/tests/zip/delete_in_phar.phpt8
-rw-r--r--ext/phar/tests/zip/delete_in_phar_confirm.phpt8
-rw-r--r--ext/phar/util.c313
-rw-r--r--ext/phar/zip.c10
27 files changed, 135 insertions, 607 deletions
diff --git a/ext/phar/Makefile.frag b/ext/phar/Makefile.frag
index ed6de9fd67..faa9db0c70 100644
--- a/ext/phar/Makefile.frag
+++ b/ext/phar/Makefile.frag
@@ -1,5 +1,5 @@
$(srcdir)/phar_path_check.c: $(srcdir)/phar_path_check.re
- @(cd $(top_srcdir); $(RE2C) -b -o ext/phar/phar_path_check.c ext/phar/phar_path_check.re)
+ @(cd $(top_srcdir); $(RE2C) --no-generation-date -b -o ext/phar/phar_path_check.c ext/phar/phar_path_check.re)
pharcmd: $(builddir)/phar.php $(builddir)/phar.phar
diff --git a/ext/phar/config.m4 b/ext/phar/config.m4
index d424060f2a..614d672eab 100644
--- a/ext/phar/config.m4
+++ b/ext/phar/config.m4
@@ -28,5 +28,7 @@ if test "$PHP_PHAR" != "no"; then
PHP_ADD_EXTENSION_DEP(phar, spl, true)
PHP_ADD_MAKEFILE_FRAGMENT
+ PHP_INSTALL_HEADERS([ext/phar], [php_phar.h])
+
PHP_OUTPUT(ext/phar/phar.1 ext/phar/phar.phar.1)
fi
diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c
index 1cbe522f11..c5c2c69448 100644
--- a/ext/phar/dirstream.c
+++ b/ext/phar/dirstream.c
@@ -103,7 +103,7 @@ static size_t phar_dir_read(php_stream *stream, char *buf, size_t count TSRMLS_D
return 0;
}
- if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(data, &key, &keylen, &unused, 0, NULL)) {
+ if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(data, &key, &keylen, &unused, 0, NULL)) {
return 0;
}
@@ -207,7 +207,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC)
zend_hash_internal_pointer_reset(manifest);
while (FAILURE != zend_hash_has_more_elements(manifest)) {
- if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) {
+ if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) {
break;
}
@@ -399,7 +399,7 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char
/* search for directory */
zend_hash_internal_pointer_reset(&phar->manifest);
while (FAILURE != zend_hash_has_more_elements(&phar->manifest)) {
- if (HASH_KEY_NON_EXISTANT !=
+ if (HASH_KEY_NON_EXISTENT !=
zend_hash_get_current_key_ex(
&phar->manifest, &key, &keylen, &unused, 0, NULL)) {
PHAR_STR(key, str_key);
@@ -633,7 +633,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_
if (!entry->is_deleted) {
for (zend_hash_internal_pointer_reset(&phar->manifest);
- HASH_KEY_NON_EXISTANT != zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL);
+ HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL);
zend_hash_move_forward(&phar->manifest)) {
PHAR_STR(key, str_key);
@@ -654,7 +654,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_
}
for (zend_hash_internal_pointer_reset(&phar->virtual_dirs);
- HASH_KEY_NON_EXISTANT != zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL);
+ HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL);
zend_hash_move_forward(&phar->virtual_dirs)) {
PHAR_STR(key, str_key);
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index ec82351410..a5488937a8 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -27,9 +27,7 @@
static void destroy_phar_data(void *pDest);
ZEND_DECLARE_MODULE_GLOBALS(phar)
-#if PHP_VERSION_ID >= 50300
char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
-#endif
/**
* set's phar->is_writeable based on the current INI value
@@ -1964,7 +1962,7 @@ woohoo:
zend_hash_internal_pointer_reset(&(PHAR_GLOBALS->phar_fname_map));
while (FAILURE != zend_hash_has_more_elements(&(PHAR_GLOBALS->phar_fname_map))) {
- if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&(PHAR_GLOBALS->phar_fname_map), &key, &keylen, &unused, 0, NULL)) {
+ if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&(PHAR_GLOBALS->phar_fname_map), &key, &keylen, &unused, 0, NULL)) {
break;
}
@@ -1994,7 +1992,7 @@ woohoo:
zend_hash_internal_pointer_reset(&cached_phars);
while (FAILURE != zend_hash_has_more_elements(&cached_phars)) {
- if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&cached_phars, &key, &keylen, &unused, 0, NULL)) {
+ if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&cached_phars, &key, &keylen, &unused, 0, NULL)) {
break;
}
@@ -3321,31 +3319,18 @@ static size_t phar_zend_stream_reader(void *handle, char *buf, size_t len TSRMLS
}
/* }}} */
-#if PHP_VERSION_ID >= 50300
static size_t phar_zend_stream_fsizer(void *handle TSRMLS_DC) /* {{{ */
{
return ((phar_archive_data*)handle)->halt_offset + 32;
} /* }}} */
-#else /* PHP_VERSION_ID */
-
-static long phar_stream_fteller_for_zend(void *handle TSRMLS_DC) /* {{{ */
-{
- return (long)php_stream_tell(phar_get_pharfp((phar_archive_data*)handle TSRMLS_CC));
-}
-/* }}} */
-#endif
-
zend_op_array *(*phar_orig_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC);
-#if PHP_VERSION_ID >= 50300
#define phar_orig_zend_open zend_stream_open_function
+
static char *phar_resolve_path(const char *filename, int filename_len TSRMLS_DC)
{
return phar_find_in_include_path((char *) filename, filename_len, NULL TSRMLS_CC);
}
-#else
-int (*phar_orig_zend_open)(const char *filename, zend_file_handle *handle TSRMLS_DC);
-#endif
static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type TSRMLS_DC) /* {{{ */
{
@@ -3378,7 +3363,6 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
}
} else if (phar->flags & PHAR_FILE_COMPRESSION_MASK) {
/* compressed phar */
-#if PHP_VERSION_ID >= 50300
file_handle->type = ZEND_HANDLE_STREAM;
/* we do our own reading directly from the phar, don't change the next line */
file_handle->handle.stream.handle = phar;
@@ -3390,18 +3374,6 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
php_stream_rewind(PHAR_GLOBALS->cached_fp[phar->phar_pos].fp) :
php_stream_rewind(phar->fp);
memset(&file_handle->handle.stream.mmap, 0, sizeof(file_handle->handle.stream.mmap));
-#else /* PHP_VERSION_ID */
- file_handle->type = ZEND_HANDLE_STREAM;
- /* we do our own reading directly from the phar, don't change the next line */
- file_handle->handle.stream.handle = phar;
- file_handle->handle.stream.reader = phar_zend_stream_reader;
- file_handle->handle.stream.closer = NULL; /* don't close - let phar handle this one */
- file_handle->handle.stream.fteller = phar_stream_fteller_for_zend;
- file_handle->handle.stream.interactive = 0;
- phar->is_persistent ?
- php_stream_rewind(PHAR_GLOBALS->cached_fp[phar->phar_pos].fp) :
- php_stream_rewind(phar->fp);
-#endif
}
}
}
@@ -3426,60 +3398,6 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type
}
/* }}} */
-#if PHP_VERSION_ID < 50300
-int phar_zend_open(const char *filename, zend_file_handle *handle TSRMLS_DC) /* {{{ */
-{
- char *arch, *entry;
- int arch_len, entry_len;
-
- /* this code is obsoleted in php 5.3 */
- entry = (char *) filename;
- if (!IS_ABSOLUTE_PATH(entry, strlen(entry)) && !strstr(entry, "://")) {
- phar_archive_data **pphar = NULL;
- char *fname;
- int fname_len;
-
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
- fname_len = strlen(fname);
-
- if (fname_len > 7 && !strncasecmp(fname, "phar://", 7)) {
- if (SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) {
- zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **) &pphar);
- if (!pphar && PHAR_G(manifest_cached)) {
- zend_hash_find(&cached_phars, arch, arch_len, (void **) &pphar);
- }
- efree(arch);
- efree(entry);
- }
- }
-
- /* retrieving an include within the current directory, so use this if possible */
- if (!(entry = phar_find_in_include_path((char *) filename, strlen(filename), NULL TSRMLS_CC))) {
- /* this file is not in the phar, use the original path */
- goto skip_phar;
- }
-
- if (SUCCESS == phar_orig_zend_open(entry, handle TSRMLS_CC)) {
- if (!handle->opened_path) {
- handle->opened_path = entry;
- }
- if (entry != filename) {
- handle->free_filename = 1;
- }
- return SUCCESS;
- }
-
- if (entry != filename) {
- efree(entry);
- }
-
- return FAILURE;
- }
-skip_phar:
- return phar_orig_zend_open(filename, handle TSRMLS_CC);
-}
-/* }}} */
-#endif
typedef zend_op_array* (zend_compile_t)(zend_file_handle*, int TSRMLS_DC);
typedef zend_compile_t* (compile_hook)(zend_compile_t *ptr);
@@ -3556,13 +3474,8 @@ PHP_MINIT_FUNCTION(phar) /* {{{ */
phar_orig_compile_file = zend_compile_file;
zend_compile_file = phar_compile_file;
-#if PHP_VERSION_ID >= 50300
phar_save_resolve_path = zend_resolve_path;
zend_resolve_path = phar_resolve_path;
-#else
- phar_orig_zend_open = zend_stream_open_function;
- zend_stream_open_function = phar_zend_open;
-#endif
phar_object_init(TSRMLS_C);
@@ -3583,11 +3496,6 @@ PHP_MSHUTDOWN_FUNCTION(phar) /* {{{ */
zend_compile_file = phar_orig_compile_file;
}
-#if PHP_VERSION_ID < 50300
- if (zend_stream_open_function == phar_zend_open) {
- zend_stream_open_function = phar_orig_zend_open;
- }
-#endif
if (PHAR_G(manifest_cached)) {
zend_hash_destroy(&(cached_phars));
zend_hash_destroy(&(cached_alias));
diff --git a/ext/phar/phar_internal.h b/ext/phar/phar_internal.h
index c9306c15f4..a24a5ace70 100644
--- a/ext/phar/phar_internal.h
+++ b/ext/phar/phar_internal.h
@@ -516,76 +516,17 @@ union _phar_entry_object {
#endif
#ifndef PHAR_MAIN
-# if PHP_VERSION_ID >= 50300
extern char *(*phar_save_resolve_path)(const char *filename, int filename_len TSRMLS_DC);
-# endif
#endif
-#if PHP_VERSION_ID < 50209
-static inline size_t phar_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC)
-{
- size_t ret = php_stream_copy_to_stream(src, dest, maxlen);
- if (len) {
- *len = ret;
- }
- if (ret) {
- return SUCCESS;
- }
- return FAILURE;
-}
-#else
# define phar_stream_copy_to_stream(src, dest, maxlen, len) _php_stream_copy_to_stream_ex((src), (dest), (maxlen), (len) STREAMS_CC TSRMLS_CC)
-#endif
-
-#if PHP_VERSION_ID >= 60000
-typedef zstr phar_zstr;
-#define PHAR_STR(a, b) \
- spprintf(&b, 0, "%s", a.s);
-#define PHAR_ZSTR(a, b) \
- b = ZSTR(a);
-#define PHAR_STR_FREE(a) \
- efree(a);
-static inline int phar_make_unicode(zstr *c_var, char *arKey, uint nKeyLength TSRMLS_DC)
-{
- int c_var_len;
- UConverter *conv = ZEND_U_CONVERTER(UG(runtime_encoding_conv));
-
- c_var->u = NULL;
- if (zend_string_to_unicode(conv, &c_var->u, &c_var_len, arKey, nKeyLength TSRMLS_CC) == FAILURE) {
-
- if (c_var->u) {
- efree(c_var->u);
- }
- return 0;
-
- }
- return c_var_len;
-}
-static inline int phar_find_key(HashTable *_SERVER, char *key, int len, void **stuff TSRMLS_DC)
-{
- if (SUCCESS == zend_hash_find(_SERVER, key, len, stuff)) {
- return 1;
- } else {
- int s = len;
- zstr var;
- s = phar_make_unicode(&var, key, len TSRMLS_CC);
- if (SUCCESS == zend_u_hash_find(_SERVER, IS_UNICODE, var, s, stuff)) {
- efree(var.u);
- return 1;
- }
- efree(var.u);
- return 0;
- }
-}
-#else
typedef char *phar_zstr;
#define PHAR_STR(a, b) \
b = a;
#define PHAR_ZSTR(a, b) \
b = a;
#define PHAR_STR_FREE(a)
-#endif
BEGIN_EXTERN_C()
diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c
index ebaa620080..7857fa71c8 100644
--- a/ext/phar/phar_object.c
+++ b/ext/phar/phar_object.c
@@ -685,11 +685,7 @@ PHP_METHOD(Phar, webPhar)
ZVAL_STRINGL(params, entry, entry_len, 1);
zp[0] = &params;
-#if PHP_VERSION_ID < 50300
- if (FAILURE == zend_fcall_info_init(rewrite, &fci, &fcc TSRMLS_CC)) {
-#else
if (FAILURE == zend_fcall_info_init(rewrite, 0, &fci, &fcc, NULL, NULL TSRMLS_CC)) {
-#endif
zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "phar error: invalid rewrite callback");
if (free_pathinfo) {
@@ -701,11 +697,7 @@ PHP_METHOD(Phar, webPhar)
fci.param_count = 1;
fci.params = zp;
-#if PHP_VERSION_ID < 50300
- ++(params->refcount);
-#else
Z_ADDREF_P(params);
-#endif
fci.retval_ptr_ptr = &retval_ptr;
if (FAILURE == zend_call_function(&fci, &fcc TSRMLS_CC)) {
@@ -729,11 +721,6 @@ PHP_METHOD(Phar, webPhar)
}
switch (Z_TYPE_P(retval_ptr)) {
-#if PHP_VERSION_ID >= 60000
- case IS_UNICODE:
- zval_unicode_to_string(retval_ptr TSRMLS_CC);
- /* break intentionally omitted */
-#endif
case IS_STRING:
efree(entry);
@@ -1155,11 +1142,7 @@ PHP_METHOD(Phar, __construct)
#else
char *fname, *alias = NULL, *error, *arch = NULL, *entry = NULL, *save_fname;
int fname_len, alias_len = 0, arch_len, entry_len, is_data;
-#if PHP_VERSION_ID < 50300
- long flags = 0;
-#else
long flags = SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS;
-#endif
long format = 0;
phar_archive_object *phar_obj;
phar_archive_data *phar_data;
@@ -1434,16 +1417,13 @@ struct _phar_t {
static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{ */
{
zval **value;
- zend_uchar key_type;
zend_bool close_fp = 1;
- ulong int_key;
struct _phar_t *p_obj = (struct _phar_t*) puser;
uint str_key_len, base_len = p_obj->l, fname_len;
phar_entry_data *data;
php_stream *fp;
size_t contents_len;
char *fname, *error = NULL, *base = p_obj->b, *opened, *save = NULL, *temp = NULL;
- phar_zstr key;
char *str_key;
zend_class_entry *ce = p_obj->c;
phar_archive_object *phar_obj = p_obj->p;
@@ -1462,11 +1442,6 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
}
switch (Z_TYPE_PP(value)) {
-#if PHP_VERSION_ID >= 60000
- case IS_UNICODE:
- zval_unicode_to_string(*(value) TSRMLS_CC);
- /* break intentionally omitted */
-#endif
case IS_STRING:
break;
case IS_RESOURCE:
@@ -1478,35 +1453,24 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
}
if (iter->funcs->get_current_key) {
- key_type = iter->funcs->get_current_key(iter, &key, &str_key_len, &int_key TSRMLS_CC);
+ zval key;
+ iter->funcs->get_current_key(iter, &key TSRMLS_CC);
if (EG(exception)) {
return ZEND_HASH_APPLY_STOP;
}
- if (key_type == HASH_KEY_IS_LONG) {
+ if (Z_TYPE(key) != IS_STRING) {
+ zval_dtor(&key);
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid key (must return a string)", ce->name);
return ZEND_HASH_APPLY_STOP;
}
- if (key_type > 9) { /* IS_UNICODE == 10 */
-#if PHP_VERSION_ID < 60000
-/* this can never happen, but fixes a compile warning */
- spprintf(&str_key, 0, "%s", key);
-#else
- spprintf(&str_key, 0, "%v", key);
- ezfree(key);
-#endif
- } else {
- PHAR_STR(key, str_key);
- }
+ str_key_len = Z_STRLEN(key);
+ str_key = estrndup(Z_STRVAL(key), str_key_len);
save = str_key;
-
- if (str_key[str_key_len - 1] == '\0') {
- str_key_len--;
- }
-
+ zval_dtor(&key);
} else {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid key (must return a string)", ce->name);
return ZEND_HASH_APPLY_STOP;
@@ -1528,13 +1492,7 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
switch (intern->type) {
case SPL_FS_DIR:
-#if PHP_VERSION_ID >= 60000
- test = spl_filesystem_object_get_path(intern, NULL, NULL TSRMLS_CC).s;
-#elif PHP_VERSION_ID >= 50300
test = spl_filesystem_object_get_path(intern, NULL TSRMLS_CC);
-#else
- test = intern->path;
-#endif
fname_len = spprintf(&fname, 0, "%s%c%s", test, DEFAULT_SLASH, intern->u.dir.entry.d_name);
php_stat(fname, fname_len, FS_IS_DIR, &dummy TSRMLS_CC);
@@ -1559,25 +1517,7 @@ static int phar_build(zend_object_iterator *iter, void *puser TSRMLS_DC) /* {{{
goto phar_spl_fileinfo;
case SPL_FS_INFO:
case SPL_FS_FILE:
-#if PHP_VERSION_ID >= 60000
- if (intern->file_name_type == IS_UNICODE) {
- zval zv;
-
- INIT_ZVAL(zv);
- Z_UNIVAL(zv) = intern->file_name;
- Z_UNILEN(zv) = intern->file_name_len;
- Z_TYPE(zv) = IS_UNICODE;
-
- zval_copy_ctor(&zv);
- zval_unicode_to_string(&zv TSRMLS_CC);
- fname = expand_filepath(Z_STRVAL(zv), NULL TSRMLS_CC);
- ezfree(Z_UNIVAL(zv));
- } else {
- fname = expand_filepath(intern->file_name.s, NULL TSRMLS_CC);
- }
-#else
fname = expand_filepath(intern->file_name, NULL TSRMLS_CC);
-#endif
if (!fname) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Could not resolve file path");
return ZEND_HASH_APPLY_STOP;
@@ -1641,32 +1581,24 @@ phar_spl_fileinfo:
}
} else {
if (iter->funcs->get_current_key) {
- key_type = iter->funcs->get_current_key(iter, &key, &str_key_len, &int_key TSRMLS_CC);
+ zval key;
+ iter->funcs->get_current_key(iter, &key TSRMLS_CC);
if (EG(exception)) {
return ZEND_HASH_APPLY_STOP;
}
- if (key_type == HASH_KEY_IS_LONG) {
+ if (Z_TYPE(key) != IS_STRING) {
+ zval_dtor(&key);
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid key (must return a string)", ce->name);
return ZEND_HASH_APPLY_STOP;
}
- if (key_type > 9) { /* IS_UNICODE == 10 */
-#if PHP_VERSION_ID < 60000
-/* this can never happen, but fixes a compile warning */
- spprintf(&str_key, 0, "%s", key);
-#else
- spprintf(&str_key, 0, "%v", key);
- ezfree(key);
-#endif
- } else {
- PHAR_STR(key, str_key);
- }
+ str_key_len = Z_STRLEN(key);
+ str_key = estrndup(Z_STRVAL(key), str_key_len);
save = str_key;
-
- if (str_key[str_key_len - 1] == '\0') str_key_len--;
+ zval_dtor(&key);
} else {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Iterator %v returned an invalid key (must return a string)", ce->name);
return ZEND_HASH_APPLY_STOP;
@@ -1838,11 +1770,7 @@ PHP_METHOD(Phar, buildFromDirectory)
INIT_PZVAL(&arg);
ZVAL_STRINGL(&arg, dir, dir_len, 0);
INIT_PZVAL(&arg2);
-#if PHP_VERSION_ID < 50300
- ZVAL_LONG(&arg2, 0);
-#else
ZVAL_LONG(&arg2, SPL_FILE_DIR_SKIPDOTS|SPL_FILE_DIR_UNIXPATHS);
-#endif
zend_call_method_with_2_params(&iter, spl_ce_RecursiveDirectoryIterator,
&spl_ce_RecursiveDirectoryIterator->constructor, "__construct", NULL, &arg, &arg2);
@@ -2335,11 +2263,7 @@ static zval *phar_convert_to_other(phar_archive_data *source, int convert, char
ALLOC_ZVAL(phar->metadata);
*phar->metadata = *t;
zval_copy_ctor(phar->metadata);
-#if PHP_VERSION_ID < 50300
- phar->metadata->refcount = 1;
-#else
Z_SET_REFCOUNT_P(phar->metadata, 1);
-#endif
phar->metadata_len = 0;
}
@@ -2387,11 +2311,7 @@ no_copy:
ALLOC_ZVAL(newentry.metadata);
*newentry.metadata = *t;
zval_copy_ctor(newentry.metadata);
-#if PHP_VERSION_ID < 50300
- newentry.metadata->refcount = 1;
-#else
Z_SET_REFCOUNT_P(newentry.metadata, 1);
-#endif
newentry.metadata_str.c = NULL;
newentry.metadata_str.len = 0;
@@ -3574,11 +3494,7 @@ PHP_METHOD(Phar, copy)
ALLOC_ZVAL(newentry.metadata);
*newentry.metadata = *t;
zval_copy_ctor(newentry.metadata);
-#if PHP_VERSION_ID < 50300
- newentry.metadata->refcount = 1;
-#else
Z_SET_REFCOUNT_P(newentry.metadata, 1);
-#endif
newentry.metadata_str.c = NULL;
newentry.metadata_str.len = 0;
@@ -4393,11 +4309,6 @@ PHP_METHOD(Phar, extractTo)
switch (Z_TYPE_P(zval_files)) {
case IS_NULL:
goto all_files;
-#if PHP_VERSION_ID >= 60000
- case IS_UNICODE:
- zval_unicode_to_string(zval_files TSRMLS_CC);
- /* break intentionally omitted */
-#endif
case IS_STRING:
filename = Z_STRVAL_P(zval_files);
filename_len = Z_STRLEN_P(zval_files);
@@ -4411,11 +4322,6 @@ PHP_METHOD(Phar, extractTo)
zval **zval_file;
if (zend_hash_index_find(Z_ARRVAL_P(zval_files), i, (void **) &zval_file) == SUCCESS) {
switch (Z_TYPE_PP(zval_file)) {
-#if PHP_VERSION_ID >= 60000
- case IS_UNICODE:
- zval_unicode_to_string(*(zval_file) TSRMLS_CC);
- /* break intentionally omitted */
-#endif
case IS_STRING:
break;
default:
@@ -5436,11 +5342,7 @@ zend_function_entry phar_exception_methods[] = {
#define REGISTER_PHAR_CLASS_CONST_LONG(class_name, const_name, value) \
zend_declare_class_constant_long(class_name, const_name, sizeof(const_name)-1, (long)value TSRMLS_CC);
-#if PHP_VERSION_ID < 50200
-# define phar_exception_get_default() zend_exception_get_default()
-#else
-# define phar_exception_get_default() zend_exception_get_default(TSRMLS_C)
-#endif
+#define phar_exception_get_default() zend_exception_get_default(TSRMLS_C)
void phar_object_init(TSRMLS_D) /* {{{ */
{
diff --git a/ext/phar/phar_path_check.c b/ext/phar/phar_path_check.c
index 22c915dfac..11d126e535 100644
--- a/ext/phar/phar_path_check.c
+++ b/ext/phar/phar_path_check.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Sun Apr 20 17:14:40 2014 */
+/* Generated by re2c 0.13.5 */
#line 1 "ext/phar/phar_path_check.re"
/*
+----------------------------------------------------------------------+
diff --git a/ext/phar/php_phar.h b/ext/phar/php_phar.h
index 554489f478..41c379bfa9 100644
--- a/ext/phar/php_phar.h
+++ b/ext/phar/php_phar.h
@@ -22,7 +22,7 @@
#ifndef PHP_PHAR_H
#define PHP_PHAR_H
-#define PHP_PHAR_VERSION "2.0.1"
+#define PHP_PHAR_VERSION "2.0.2"
#include "ext/standard/basic_functions.h"
extern zend_module_entry phar_module_entry;
@@ -31,9 +31,11 @@ extern zend_module_entry phar_module_entry;
#ifdef PHP_WIN32
#define PHP_PHAR_API __declspec(dllexport)
#else
-#define PHP_PHAR_API
+#define PHP_PHAR_API PHPAPI
#endif
+PHP_PHAR_API int phar_resolve_alias(char *alias, int alias_len, char **filename, int *filename_len TSRMLS_DC);
+
#endif /* PHP_PHAR_H */
diff --git a/ext/phar/stream.c b/ext/phar/stream.c
index 4101008549..5db866c422 100644
--- a/ext/phar/stream.c
+++ b/ext/phar/stream.c
@@ -635,7 +635,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags,
zend_hash_internal_pointer_reset_ex(&phar->mounted_dirs, &pos);
while (FAILURE != zend_hash_has_more_elements_ex(&phar->mounted_dirs, &pos)) {
- if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, &pos)) {
+ if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, &pos)) {
break;
}
PHAR_STR(key, str_key);
@@ -918,7 +918,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char
uint to_len = strlen(resource_to->path+1);
for (zend_hash_internal_pointer_reset(&phar->manifest);
- HASH_KEY_NON_EXISTANT != (key_type = zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL)) &&
+ HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL)) &&
SUCCESS == zend_hash_get_current_data(&phar->manifest, (void **) &entry);
zend_hash_move_forward(&phar->manifest)) {
@@ -942,17 +942,13 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char
entry->filename_len = new_key_len;
PHAR_ZSTR(new_str_key, new_key);
-#if PHP_VERSION_ID < 50300
- zend_hash_update_current_key_ex(&phar->manifest, key_type, new_key, new_key_len, 0, NULL);
-#else
zend_hash_update_current_key_ex(&phar->manifest, key_type, new_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL);
-#endif
}
PHAR_STR_FREE(str_key);
}
for (zend_hash_internal_pointer_reset(&phar->virtual_dirs);
- HASH_KEY_NON_EXISTANT != (key_type = zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL));
+ HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL));
zend_hash_move_forward(&phar->virtual_dirs)) {
PHAR_STR(key, str_key);
@@ -968,18 +964,14 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char
new_str_key[new_key_len] = 0;
PHAR_ZSTR(new_str_key, new_key);
-#if PHP_VERSION_ID < 50300
- zend_hash_update_current_key_ex(&phar->virtual_dirs, key_type, new_key, new_key_len, 0, NULL);
-#else
zend_hash_update_current_key_ex(&phar->virtual_dirs, key_type, new_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL);
-#endif
efree(new_str_key);
}
PHAR_STR_FREE(str_key);
}
for (zend_hash_internal_pointer_reset(&phar->mounted_dirs);
- HASH_KEY_NON_EXISTANT != (key_type = zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &key_len, &unused, 0, NULL)) &&
+ HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &key_len, &unused, 0, NULL)) &&
SUCCESS == zend_hash_get_current_data(&phar->mounted_dirs, (void **) &entry);
zend_hash_move_forward(&phar->mounted_dirs)) {
@@ -996,11 +988,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char
new_str_key[new_key_len] = 0;
PHAR_ZSTR(new_str_key, new_key);
-#if PHP_VERSION_ID < 50300
- zend_hash_update_current_key_ex(&phar->mounted_dirs, key_type, new_key, new_key_len, 0, NULL);
-#else
zend_hash_update_current_key_ex(&phar->mounted_dirs, key_type, new_key, new_key_len, 0, HASH_UPDATE_KEY_ANYWAY, NULL);
-#endif
efree(new_str_key);
}
PHAR_STR_FREE(str_key);
diff --git a/ext/phar/tests/create_new_and_modify.phpt b/ext/phar/tests/create_new_and_modify.phpt
index d6c469d9cb..c03576cb2c 100644
--- a/ext/phar/tests/create_new_and_modify.phpt
+++ b/ext/phar/tests/create_new_and_modify.phpt
@@ -21,6 +21,14 @@ $sig1 = $phar->getSignature();
include $pname . '/a.php';
+if (function_exists("opcache_get_status")) {
+ $status = opcache_get_status();
+ if ($status["opcache_enabled"]) {
+ ini_set("opcache.revalidate_freq", "0");
+ sleep(2);
+ }
+}
+
file_put_contents($pname .'/a.php', "modified!\n");
file_put_contents($pname .'/b.php', "another!\n");
diff --git a/ext/phar/tests/delete_in_phar.phpt b/ext/phar/tests/delete_in_phar.phpt
index 4842d27913..d28f136f77 100644
--- a/ext/phar/tests/delete_in_phar.phpt
+++ b/ext/phar/tests/delete_in_phar.phpt
@@ -15,6 +15,15 @@ $files = array();
$files['a.php'] = '<?php echo "This is a\n"; ?>';
$files['b.php'] = '<?php echo "This is b\n"; ?>';
$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+
+if (function_exists("opcache_get_status")) {
+ $status = opcache_get_status();
+ if ($status["opcache_enabled"]) {
+ ini_set("opcache.revalidate_freq", "0");
+ sleep(2);
+ }
+}
+
include 'files/phar_test.inc';
include $pname . '/a.php';
diff --git a/ext/phar/tests/delete_in_phar_confirm.phpt b/ext/phar/tests/delete_in_phar_confirm.phpt
index 13a8d0db29..0d4eb1e2aa 100644
--- a/ext/phar/tests/delete_in_phar_confirm.phpt
+++ b/ext/phar/tests/delete_in_phar_confirm.phpt
@@ -15,6 +15,15 @@ $files = array();
$files['a.php'] = '<?php echo "This is a\n"; ?>';
$files['b.php'] = '<?php echo "This is b\n"; ?>';
$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+
+if (function_exists("opcache_get_status")) {
+ $status = opcache_get_status();
+ if ($status["opcache_enabled"]) {
+ ini_set("opcache.revalidate_freq", "0");
+ sleep(2);
+ }
+}
+
include 'files/phar_test.inc';
include $pname . '/a.php';
diff --git a/ext/phar/tests/phar_commitwrite.phpt b/ext/phar/tests/phar_commitwrite.phpt
index 8e36681338..36d473e5c2 100644
--- a/ext/phar/tests/phar_commitwrite.phpt
+++ b/ext/phar/tests/phar_commitwrite.phpt
@@ -39,4 +39,4 @@ Phar::mapPhar('brandnewphar.phar');
include 'phar://brandnewphar.phar/startup.php';
__HALT_COMPILER(); ?>
"
-===DONE===
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_create_in_cwd.phpt b/ext/phar/tests/phar_create_in_cwd.phpt
index 1828fe745f..4b0e6594fb 100644
--- a/ext/phar/tests/phar_create_in_cwd.phpt
+++ b/ext/phar/tests/phar_create_in_cwd.phpt
@@ -42,4 +42,4 @@ Phar::mapPhar('brandnewphar.phar');
include 'phar://brandnewphar.phar/startup.php';
__HALT_COMPILER(); ?>
"
-===DONE===
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_gobyebye.phpt b/ext/phar/tests/phar_gobyebye.phpt
index 93e153bdf2..608e950768 100644
--- a/ext/phar/tests/phar_gobyebye.phpt
+++ b/ext/phar/tests/phar_gobyebye.phpt
@@ -44,4 +44,4 @@ bool(false)
bool(false)
Warning: opendir(foo/hi): failed to open dir: No such file or directory in phar://%sphar_gobyebye.phar.php/foo/hi on line %d
-===DONE===
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phar_mount.phpt b/ext/phar/tests/phar_mount.phpt
index 73bd489a2d..80f8cda389 100644
--- a/ext/phar/tests/phar_mount.phpt
+++ b/ext/phar/tests/phar_mount.phpt
@@ -60,4 +60,4 @@ Mounting of testit to %sphar_mount.php within phar %sphar_mount.phar.tar failed
Mounting of /oops to /home/oops/../../etc/passwd: within phar %sphar_mount.phar.php failed
<?php
$fname = dirname(__FILE__) . '/' . basename(
-===DONE===
+===DONE=== \ No newline at end of file
diff --git a/ext/phar/tests/phpinfo_001.phpt b/ext/phar/tests/phpinfo_001.phpt
index 5de74dac0e..d99ccd1803 100644
--- a/ext/phar/tests/phpinfo_001.phpt
+++ b/ext/phar/tests/phpinfo_001.phpt
@@ -26,7 +26,7 @@ phpinfo(INFO_MODULES);
Phar: PHP Archive support => enabled
Phar EXT version => %s
Phar API version => 1.1.1
-SVN revision => %sRevision: %s $
+SVN revision => %sId: %s $
Phar-based phar archives => enabled
Tar-based phar archives => enabled
ZIP-based phar archives => enabled
@@ -48,7 +48,7 @@ Phar
Phar: PHP Archive support => enabled
Phar EXT version => %s
Phar API version => 1.1.1
-SVN revision => %sRevision: %s $
+SVN revision => %sId: %s $
Phar-based phar archives => enabled
Tar-based phar archives => enabled
ZIP-based phar archives => enabled
diff --git a/ext/phar/tests/phpinfo_002.phpt b/ext/phar/tests/phpinfo_002.phpt
index da6db9571b..ef505fedad 100644
--- a/ext/phar/tests/phpinfo_002.phpt
+++ b/ext/phar/tests/phpinfo_002.phpt
@@ -24,7 +24,7 @@ Phar
Phar: PHP Archive support => enabled
Phar EXT version => %s
Phar API version => 1.1.1
-SVN revision => %sRevision: %s $
+SVN revision => %sId: %s $
Phar-based phar archives => enabled
Tar-based phar archives => enabled
ZIP-based phar archives => enabled
diff --git a/ext/phar/tests/phpinfo_004.phpt b/ext/phar/tests/phpinfo_004.phpt
index c49205c147..24263f07be 100644
--- a/ext/phar/tests/phpinfo_004.phpt
+++ b/ext/phar/tests/phpinfo_004.phpt
@@ -29,7 +29,7 @@ phpinfo(INFO_MODULES);
<tr class="h"><th>Phar: PHP Archive support</th><th>enabled</th></tr>
<tr><td class="e">Phar EXT version </td><td class="v">%s </td></tr>
<tr><td class="e">Phar API version </td><td class="v">1.1.1 </td></tr>
-<tr><td class="e">SVN revision </td><td class="v">%sRevision: %s $ </td></tr>
+<tr><td class="e">SVN revision </td><td class="v">%sId: %s $ </td></tr>
<tr><td class="e">Phar-based phar archives </td><td class="v">enabled </td></tr>
<tr><td class="e">Tar-based phar archives </td><td class="v">enabled </td></tr>
<tr><td class="e">ZIP-based phar archives </td><td class="v">enabled </td></tr>
@@ -53,7 +53,7 @@ Phar based on pear/PHP_Archive, original concept by Davey Shafik.<br />Phar full
<tr class="h"><th>Phar: PHP Archive support</th><th>enabled</th></tr>
<tr><td class="e">Phar EXT version </td><td class="v">%s </td></tr>
<tr><td class="e">Phar API version </td><td class="v">1.1.1 </td></tr>
-<tr><td class="e">SVN revision </td><td class="v">%sRevision: %s $ </td></tr>
+<tr><td class="e">SVN revision </td><td class="v">%sId: %s $ </td></tr>
<tr><td class="e">Phar-based phar archives </td><td class="v">enabled </td></tr>
<tr><td class="e">Tar-based phar archives </td><td class="v">enabled </td></tr>
<tr><td class="e">ZIP-based phar archives </td><td class="v">enabled </td></tr>
diff --git a/ext/phar/tests/tar/create_new_and_modify.phpt b/ext/phar/tests/tar/create_new_and_modify.phpt
index 8062fda769..905bfabc82 100644
--- a/ext/phar/tests/tar/create_new_and_modify.phpt
+++ b/ext/phar/tests/tar/create_new_and_modify.phpt
@@ -15,6 +15,14 @@ $pname = 'phar://' . $fname;
file_put_contents($pname . '/a.php', "brand new!\n");
+if (function_exists("opcache_get_status")) {
+ $status = opcache_get_status();
+ if ($status["opcache_enabled"]) {
+ ini_set("opcache.revalidate_freq", "0");
+ sleep(2);
+ }
+}
+
$phar = new Phar($fname);
var_dump($phar->isFileFormat(Phar::TAR));
$sig1 = md5_file($fname);
diff --git a/ext/phar/tests/tar/delete_in_phar.phpt b/ext/phar/tests/tar/delete_in_phar.phpt
index 91ef4a2046..1982b6bda9 100644
--- a/ext/phar/tests/tar/delete_in_phar.phpt
+++ b/ext/phar/tests/tar/delete_in_phar.phpt
@@ -18,6 +18,14 @@ $phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
$phar->setStub('<?php __HALT_COMPILER(); ?>');
$phar->stopBuffering();
+if (function_exists("opcache_get_status")) {
+ $status = opcache_get_status();
+ if ($status["opcache_enabled"]) {
+ ini_set("opcache.revalidate_freq", "0");
+ sleep(2);
+ }
+}
+
include $alias . '/a.php';
include $alias . '/b.php';
include $alias . '/b/c.php';
diff --git a/ext/phar/tests/tar/delete_in_phar_confirm.phpt b/ext/phar/tests/tar/delete_in_phar_confirm.phpt
index 707bcbd0ed..7593ebc1fb 100644
--- a/ext/phar/tests/tar/delete_in_phar_confirm.phpt
+++ b/ext/phar/tests/tar/delete_in_phar_confirm.phpt
@@ -18,6 +18,14 @@ $phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
$phar->setStub('<?php __HALT_COMPILER(); ?>');
$phar->stopBuffering();
+if (function_exists("opcache_get_status")) {
+ $status = opcache_get_status();
+ if ($status["opcache_enabled"]) {
+ ini_set("opcache.revalidate_freq", "0");
+ sleep(2);
+ }
+}
+
include $alias . '/a.php';
include $alias . '/b.php';
include $alias . '/b/c.php';
diff --git a/ext/phar/tests/zip/create_new_and_modify.phpt b/ext/phar/tests/zip/create_new_and_modify.phpt
index 5a3ec3317b..55d69cca0e 100644
--- a/ext/phar/tests/zip/create_new_and_modify.phpt
+++ b/ext/phar/tests/zip/create_new_and_modify.phpt
@@ -15,6 +15,14 @@ $pname = 'phar://' . $fname;
file_put_contents($pname . '/a.php', "brand new!\n");
+if (function_exists("opcache_get_status")) {
+ $status = opcache_get_status();
+ if ($status["opcache_enabled"]) {
+ ini_set("opcache.revalidate_freq", "0");
+ sleep(2);
+ }
+}
+
$phar = new Phar($fname);
var_dump($phar->isFileFormat(Phar::ZIP));
$sig1 = md5_file($fname);
diff --git a/ext/phar/tests/zip/delete_in_phar.phpt b/ext/phar/tests/zip/delete_in_phar.phpt
index b7bda7ca4b..f01280013f 100644
--- a/ext/phar/tests/zip/delete_in_phar.phpt
+++ b/ext/phar/tests/zip/delete_in_phar.phpt
@@ -18,6 +18,14 @@ $phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
$phar->setStub('<?php __HALT_COMPILER(); ?>');
$phar->stopBuffering();
+if (function_exists("opcache_get_status")) {
+ $status = opcache_get_status();
+ if ($status["opcache_enabled"]) {
+ ini_set("opcache.revalidate_freq", "0");
+ sleep(2);
+ }
+}
+
include $alias . '/a.php';
include $alias . '/b.php';
include $alias . '/b/c.php';
diff --git a/ext/phar/tests/zip/delete_in_phar_confirm.phpt b/ext/phar/tests/zip/delete_in_phar_confirm.phpt
index fdd0b42b5c..0080499177 100644
--- a/ext/phar/tests/zip/delete_in_phar_confirm.phpt
+++ b/ext/phar/tests/zip/delete_in_phar_confirm.phpt
@@ -18,6 +18,14 @@ $phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
$phar->setStub('<?php __HALT_COMPILER(); ?>');
$phar->stopBuffering();
+if (function_exists("opcache_get_status")) {
+ $status = opcache_get_status();
+ if ($status["opcache_enabled"]) {
+ ini_set("opcache.revalidate_freq", "0");
+ sleep(2);
+ }
+}
+
include $alias . '/a.php';
include $alias . '/b.php';
include $alias . '/b/c.php';
diff --git a/ext/phar/util.c b/ext/phar/util.c
index cd473ad425..d8152cf459 100644
--- a/ext/phar/util.c
+++ b/ext/phar/util.c
@@ -41,10 +41,6 @@
static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end, char *key, int key_len, char **signature, int *signature_len TSRMLS_DC);
#endif
-#if !defined(PHP_VERSION_ID) || PHP_VERSION_ID < 50300
-extern php_stream_wrapper php_stream_phar_wrapper;
-#endif
-
/* for links to relative location, prepend cwd of the entry */
static char *phar_get_link_location(phar_entry_info *entry TSRMLS_DC) /* {{{ */
{
@@ -256,7 +252,6 @@ int phar_mount_entry(phar_archive_data *phar, char *filename, int filename_len,
char *phar_find_in_include_path(char *filename, int filename_len, phar_archive_data **pphar TSRMLS_DC) /* {{{ */
{
-#if PHP_VERSION_ID >= 50300
char *path, *fname, *arch, *entry, *ret, *test;
int arch_len, entry_len, fname_len, ret_len;
phar_archive_data *phar;
@@ -344,223 +339,6 @@ splitted:
}
return ret;
-#else /* PHP 5.2 */
- char resolved_path[MAXPATHLEN];
- char trypath[MAXPATHLEN];
- char *ptr, *end, *path = PG(include_path);
- php_stream_wrapper *wrapper;
- const char *p;
- int n = 0;
- char *fname, *arch, *entry, *ret, *test;
- int arch_len, entry_len;
- phar_archive_data *phar = NULL;
-
- if (!filename) {
- return NULL;
- }
-
- if (!zend_is_executing(TSRMLS_C) || !PHAR_G(cwd)) {
- goto doit;
- }
-
- fname = (char*)zend_get_executed_filename(TSRMLS_C);
-
- if (SUCCESS != phar_split_fname(fname, strlen(fname), &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) {
- goto doit;
- }
-
- efree(entry);
-
- if (*filename == '.') {
- int try_len;
-
- if (FAILURE == phar_get_archive(&phar, arch, arch_len, NULL, 0, NULL TSRMLS_CC)) {
- efree(arch);
- goto doit;
- }
-
- try_len = filename_len;
- test = phar_fix_filepath(estrndup(filename, filename_len), &try_len, 1 TSRMLS_CC);
-
- if (*test == '/') {
- if (zend_hash_exists(&(phar->manifest), test + 1, try_len - 1)) {
- spprintf(&ret, 0, "phar://%s%s", arch, test);
- efree(arch);
- efree(test);
- return ret;
- }
- } else {
- if (zend_hash_exists(&(phar->manifest), test, try_len)) {
- spprintf(&ret, 0, "phar://%s/%s", arch, test);
- efree(arch);
- efree(test);
- return ret;
- }
- }
-
- efree(test);
- }
-
- efree(arch);
-doit:
- if (*filename == '.' || IS_ABSOLUTE_PATH(filename, filename_len) || !path || !*path) {
- if (tsrm_realpath(filename, resolved_path TSRMLS_CC)) {
- return estrdup(resolved_path);
- } else {
- return NULL;
- }
- }
-
- /* test for stream wrappers and return */
- for (p = filename; p - filename < filename_len && (isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'); ++p, ++n);
-
- if (n < filename_len - 3 && (*p == ':') && (!strncmp("//", p+1, 2) || ( filename_len > 4 && !memcmp("data", filename, 4)))) {
- /* found stream wrapper, this is an absolute path until stream wrappers implement realpath */
- return estrndup(filename, filename_len);
- }
-
- ptr = (char *) path;
- while (ptr && *ptr) {
- int len, is_stream_wrapper = 0, maybe_stream = 1;
-
- end = strchr(ptr, DEFAULT_DIR_SEPARATOR);
-#ifndef PHP_WIN32
- /* search for stream wrapper */
- if (end - ptr <= 1) {
- maybe_stream = 0;
- goto not_stream;
- }
-
- for (p = ptr, n = 0; p < end && (isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'); ++p, ++n);
-
- if (n == end - ptr && *p && !strncmp("//", p+1, 2)) {
- is_stream_wrapper = 1;
- /* seek to real end of include_path portion */
- end = strchr(end + 1, DEFAULT_DIR_SEPARATOR);
- } else {
- maybe_stream = 0;
- }
-not_stream:
-#endif
- if (end) {
- if ((end-ptr) + 1 + filename_len + 1 >= MAXPATHLEN) {
- ptr = end + 1;
- continue;
- }
-
- memcpy(trypath, ptr, end-ptr);
- len = end-ptr;
- trypath[end-ptr] = '/';
- memcpy(trypath+(end-ptr)+1, filename, filename_len+1);
- ptr = end+1;
- } else {
- len = strlen(ptr);
-
- if (len + 1 + filename_len + 1 >= MAXPATHLEN) {
- break;
- }
-
- memcpy(trypath, ptr, len);
- trypath[len] = '/';
- memcpy(trypath+len+1, filename, filename_len+1);
- ptr = NULL;
- }
-
- if (!is_stream_wrapper && maybe_stream) {
- /* search for stream wrapper */
- for (p = trypath, n = 0; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; ++p, ++n);
- }
-
- if (is_stream_wrapper || (n < len - 3 && (*p == ':') && (n > 1) && (!strncmp("//", p+1, 2) || !memcmp("data", trypath, 4)))) {
- char *actual;
-
- wrapper = php_stream_locate_url_wrapper(trypath, &actual, STREAM_OPEN_FOR_INCLUDE TSRMLS_CC);
- if (wrapper == &php_plain_files_wrapper) {
- strlcpy(trypath, actual, sizeof(trypath));
- } else if (!wrapper) {
- /* if wrapper is NULL, there was a mal-formed include_path stream wrapper, so skip this ptr */
- continue;
- } else {
- if (wrapper->wops->url_stat) {
- php_stream_statbuf ssb;
-
- if (SUCCESS == wrapper->wops->url_stat(wrapper, trypath, 0, &ssb, NULL TSRMLS_CC)) {
- if (wrapper == &php_stream_phar_wrapper) {
- char *arch, *entry;
- int arch_len, entry_len, ret_len;
-
- ret_len = strlen(trypath);
- /* found phar:// */
-
- if (SUCCESS != phar_split_fname(trypath, ret_len, &arch, &arch_len, &entry, &entry_len, 1, 0 TSRMLS_CC)) {
- return estrndup(trypath, ret_len);
- }
-
- zend_hash_find(&(PHAR_GLOBALS->phar_fname_map), arch, arch_len, (void **) &pphar);
-
- if (!pphar && PHAR_G(manifest_cached)) {
- zend_hash_find(&cached_phars, arch, arch_len, (void **) &pphar);
- }
-
- efree(arch);
- efree(entry);
-
- return estrndup(trypath, ret_len);
- }
- return estrdup(trypath);
- }
- }
- continue;
- }
- }
-
- if (tsrm_realpath(trypath, resolved_path TSRMLS_CC)) {
- return estrdup(resolved_path);
- }
- } /* end provided path */
-
- /* check in calling scripts' current working directory as a fall back case */
- if (zend_is_executing(TSRMLS_C)) {
- char *exec_fname = (char*)zend_get_executed_filename(TSRMLS_C);
- int exec_fname_length = strlen(exec_fname);
- const char *p;
- int n = 0;
-
- while ((--exec_fname_length >= 0) && !IS_SLASH(exec_fname[exec_fname_length]));
- if (exec_fname && exec_fname[0] != '[' &&
- exec_fname_length > 0 &&
- exec_fname_length + 1 + filename_len + 1 < MAXPATHLEN) {
- memcpy(trypath, exec_fname, exec_fname_length + 1);
- memcpy(trypath+exec_fname_length + 1, filename, filename_len+1);
-
- /* search for stream wrapper */
- for (p = trypath; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; ++p, ++n);
-
- if (n < exec_fname_length - 3 && (*p == ':') && (n > 1) && (!strncmp("//", p+1, 2) || !memcmp("data", trypath, 4))) {
- char *actual;
-
- wrapper = php_stream_locate_url_wrapper(trypath, &actual, STREAM_OPEN_FOR_INCLUDE TSRMLS_CC);
-
- if (wrapper == &php_plain_files_wrapper) {
- /* this should never technically happen, but we'll leave it here for completeness */
- strlcpy(trypath, actual, sizeof(trypath));
- } else if (!wrapper) {
- /* if wrapper is NULL, there was a malformed include_path stream wrapper
- this also should be impossible */
- return NULL;
- } else {
- return estrdup(trypath);
- }
- }
-
- if (tsrm_realpath(trypath, resolved_path TSRMLS_CC)) {
- return estrdup(resolved_path);
- }
- }
- }
-
- return NULL;
-#endif /* PHP 5.2 */
}
/* }}} */
@@ -850,11 +628,6 @@ int phar_open_archive_fp(phar_archive_data *phar TSRMLS_DC) /* {{{ */
if (phar_get_pharfp(phar TSRMLS_CC)) {
return SUCCESS;
}
-#if PHP_API_VERSION < 20100412
- if (PG(safe_mode) && (!php_checkuid(phar->fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) {
- return FAILURE;
- }
-#endif
if (php_check_open_basedir(phar->fname TSRMLS_CC)) {
return FAILURE;
@@ -1031,47 +804,12 @@ int phar_open_entry_fp(phar_entry_info *entry, char **error, int follow_links TS
}
/* }}} */
-#if defined(PHP_VERSION_ID) && PHP_VERSION_ID < 50202
-typedef struct {
- char *data;
- size_t fpos;
- size_t fsize;
- size_t smax;
- int mode;
- php_stream **owner_ptr;
-} php_stream_memory_data;
-#endif
-
int phar_create_writeable_entry(phar_archive_data *phar, phar_entry_info *entry, char **error TSRMLS_DC) /* {{{ */
{
if (entry->fp_type == PHAR_MOD) {
/* already newly created, truncate */
-#if PHP_VERSION_ID >= 50202
php_stream_truncate_set_size(entry->fp, 0);
-#else
- if (php_stream_is(entry->fp, PHP_STREAM_IS_TEMP)) {
- if (php_stream_is(*(php_stream**)entry->fp->abstract, PHP_STREAM_IS_MEMORY)) {
- php_stream *inner = *(php_stream**)entry->fp->abstract;
- php_stream_memory_data *memfp = (php_stream_memory_data*)inner->abstract;
- memfp->fpos = 0;
- memfp->fsize = 0;
- } else if (php_stream_is(*(php_stream**)entry->fp->abstract, PHP_STREAM_IS_STDIO)) {
- php_stream_truncate_set_size(*(php_stream**)entry->fp->abstract, 0);
- } else {
- if (error) {
- spprintf(error, 0, "phar error: file \"%s\" cannot be opened for writing, no truncate support", phar->fname);
- }
- return FAILURE;
- }
- } else if (php_stream_is(entry->fp, PHP_STREAM_IS_STDIO)) {
- php_stream_truncate_set_size(entry->fp, 0);
- } else {
- if (error) {
- spprintf(error, 0, "phar error: file \"%s\" cannot be opened for writing, no truncate support", phar->fname);
- }
- return FAILURE;
- }
-#endif
+
entry->old_flags = entry->flags;
entry->is_modified = 1;
phar->is_modified = 1;
@@ -1185,6 +923,18 @@ phar_entry_info * phar_open_jit(phar_archive_data *phar, phar_entry_info *entry,
}
/* }}} */
+PHP_PHAR_API int phar_resolve_alias(char *alias, int alias_len, char **filename, int *filename_len TSRMLS_DC) /* {{{ */ {
+ phar_archive_data **fd_ptr;
+ if (PHAR_GLOBALS->phar_alias_map.arBuckets
+ && SUCCESS == zend_hash_find(&(PHAR_GLOBALS->phar_alias_map), alias, alias_len, (void**)&fd_ptr)) {
+ *filename = (*fd_ptr)->fname;
+ *filename_len = (*fd_ptr)->fname_len;
+ return SUCCESS;
+ }
+ return FAILURE;
+}
+/* }}} */
+
int phar_free_alias(phar_archive_data *phar, char *alias, int alias_len TSRMLS_DC) /* {{{ */
{
if (phar->refcount || phar->is_persistent) {
@@ -1556,7 +1306,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in
zend_hash_internal_pointer_reset(&phar->mounted_dirs);
while (FAILURE != zend_hash_has_more_elements(&phar->mounted_dirs)) {
- if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, NULL)) {
+ if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, NULL)) {
break;
}
@@ -1677,11 +1427,7 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
Z_TYPE_P(zdata) = IS_STRING;
Z_STRLEN_P(zdata) = end;
-#if PHP_MAJOR_VERSION > 5
- if (end != (off_t) php_stream_copy_to_mem(fp, (void **) &(Z_STRVAL_P(zdata)), (size_t) end, 0)) {
-#else
if (end != (off_t) php_stream_copy_to_mem(fp, &(Z_STRVAL_P(zdata)), (size_t) end, 0)) {
-#endif
zval_dtor(zdata);
zval_dtor(zsig);
zval_dtor(zkey);
@@ -1693,11 +1439,7 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
return FAILURE;
}
-#if PHP_VERSION_ID < 50300
- if (FAILURE == zend_fcall_info_init(openssl, &fci, &fcc TSRMLS_CC)) {
-#else
if (FAILURE == zend_fcall_info_init(openssl, 0, &fci, &fcc, NULL, NULL TSRMLS_CC)) {
-#endif
zval_dtor(zdata);
zval_dtor(zsig);
zval_dtor(zkey);
@@ -1711,13 +1453,6 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
fci.param_count = 3;
fci.params = zp;
-#if PHP_VERSION_ID < 50300
- ++(zdata->refcount);
- if (!is_sign) {
- ++(zsig->refcount);
- }
- ++(zkey->refcount);
-#else
Z_ADDREF_P(zdata);
if (is_sign) {
Z_SET_ISREF_P(zsig);
@@ -1725,7 +1460,7 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
Z_ADDREF_P(zsig);
}
Z_ADDREF_P(zkey);
-#endif
+
fci.retval_ptr_ptr = &retval_ptr;
if (FAILURE == zend_call_function(&fci, &fcc TSRMLS_CC)) {
@@ -1742,21 +1477,15 @@ static int phar_call_openssl_signverify(int is_sign, php_stream *fp, off_t end,
zval_dtor(openssl);
efree(openssl);
-#if PHP_VERSION_ID < 50300
- --(zdata->refcount);
- if (!is_sign) {
- --(zsig->refcount);
- }
- --(zkey->refcount);
-#else
Z_DELREF_P(zdata);
+
if (is_sign) {
Z_UNSET_ISREF_P(zsig);
} else {
Z_DELREF_P(zsig);
}
Z_DELREF_P(zkey);
-#endif
+
zval_dtor(zdata);
efree(zdata);
zval_dtor(zkey);
@@ -2282,11 +2011,7 @@ static int phar_update_cached_entry(void *data, void *argument) /* {{{ */
ALLOC_ZVAL(entry->metadata);
*entry->metadata = *t;
zval_copy_ctor(entry->metadata);
-#if PHP_VERSION_ID < 50300
- entry->metadata->refcount = 1;
-#else
Z_SET_REFCOUNT_P(entry->metadata, 1);
-#endif
entry->metadata_str.c = NULL;
entry->metadata_str.len = 0;
}
@@ -2330,11 +2055,7 @@ static void phar_copy_cached_phar(phar_archive_data **pphar TSRMLS_DC) /* {{{ */
ALLOC_ZVAL(phar->metadata);
*phar->metadata = *t;
zval_copy_ctor(phar->metadata);
-#if PHP_VERSION_ID < 50300
- phar->metadata->refcount = 1;
-#else
Z_SET_REFCOUNT_P(phar->metadata, 1);
-#endif
}
}
diff --git a/ext/phar/zip.c b/ext/phar/zip.c
index 79203c8a9b..ba03687315 100644
--- a/ext/phar/zip.c
+++ b/ext/phar/zip.c
@@ -578,10 +578,6 @@ foundit:
/* construct actual offset to file start - local extra_len can be different from central extra_len */
entry.offset = entry.offset_abs =
sizeof(local) + entry.header_offset + PHAR_GET_16(local.filename_len) + PHAR_GET_16(local.extra_len);
-#if PHP_VERSION_ID < 50207
- /* work around Bug #46147 */
- fp->writepos = fp->readpos = 0;
-#endif
php_stream_seek(fp, entry.offset, SEEK_SET);
/* these next lines should be for php < 5.2.6 after 5.3 filters are fixed */
fp->writepos = 0;
@@ -605,9 +601,6 @@ foundit:
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
pefree(entry.filename, entry.is_persistent);
-#if PHP_VERSION_ID < 50207
- PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)");
-#endif
PHAR_ZIP_FAIL("unable to read in alias, truncated");
}
@@ -626,9 +619,6 @@ foundit:
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
pefree(entry.filename, entry.is_persistent);
-#if PHP_VERSION_ID < 50207
- PHAR_ZIP_FAIL("unable to read in alias, truncated (PHP 5.2.7 and newer has a potential fix for this problem)");
-#endif
PHAR_ZIP_FAIL("unable to read in alias, truncated");
}