Merge branch 'PHP-5.3' into PHP-5.4

* PHP-5.3:
  - Removed PHP 6 checks
This commit is contained in:
Felipe Pena 2012-08-21 20:15:48 -03:00
commit b0dbf71466
5 changed files with 9 additions and 167 deletions

View File

@ -2647,11 +2647,8 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert,
len = -len;
}
user_stub = 0;
#if PHP_MAJOR_VERSION >= 6
if (!(len = php_stream_copy_to_mem(stubfile, (void **) &user_stub, len, 0)) || !user_stub) {
#else
if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
#endif
if (closeoldfile) {
php_stream_close(oldfile);
}

View File

@ -58,9 +58,6 @@ static int phar_file_type(HashTable *mimes, char *file, char **mime_type TSRMLS_
static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char *basename, int request_uri_len TSRMLS_DC) /* {{{ */
{
#if PHP_MAJOR_VERSION >= 6
int is_unicode = 0;
#endif
HashTable *_SERVER;
zval **stuff;
char *path_info;
@ -76,18 +73,7 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
_SERVER = Z_ARRVAL_P(PG(http_globals)[TRACK_VARS_SERVER]);
/* PATH_INFO and PATH_TRANSLATED should always be munged */
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(_SERVER, "PATH_INFO", sizeof("PATH_INFO"), (void **) &stuff TSRMLS_CC)) {
if (Z_TYPE_PP(stuff) == IS_UNICODE) {
is_unicode = 1;
zval_unicode_to_string(*stuff TSRMLS_CC);
} else {
is_unicode = 0;
}
#else
if (SUCCESS == zend_hash_find(_SERVER, "PATH_INFO", sizeof("PATH_INFO"), (void **) &stuff)) {
#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
@ -96,38 +82,19 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
#if PHP_MAJOR_VERSION >= 6
if (is_unicode) {
zval_string_to_unicode(*stuff TSRMLS_CC);
}
#endif
zend_hash_update(_SERVER, "PHAR_PATH_INFO", sizeof("PHAR_PATH_INFO"), &temp, sizeof(zval **), NULL);
}
}
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(_SERVER, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void **) &stuff TSRMLS_CC)) {
if (Z_TYPE_PP(stuff) == IS_UNICODE) {
is_unicode = 1;
zval_unicode_to_string(*stuff TSRMLS_CC);
} else {
is_unicode = 0;
}
#else
if (SUCCESS == zend_hash_find(_SERVER, "PATH_TRANSLATED", sizeof("PATH_TRANSLATED"), (void **) &stuff)) {
#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
Z_STRLEN_PP(stuff) = spprintf(&(Z_STRVAL_PP(stuff)), 4096, "phar://%s%s", fname, entry);
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
#if PHP_MAJOR_VERSION >= 6
if (is_unicode) {
zval_string_to_unicode(*stuff TSRMLS_CC);
}
#endif
zend_hash_update(_SERVER, "PHAR_PATH_TRANSLATED", sizeof("PHAR_PATH_TRANSLATED"), (void *) &temp, sizeof(zval **), NULL);
}
@ -136,18 +103,7 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
}
if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_REQUEST_URI) {
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(_SERVER, "REQUEST_URI", sizeof("REQUEST_URI"), (void **) &stuff TSRMLS_CC)) {
if (Z_TYPE_PP(stuff) == IS_UNICODE) {
is_unicode = 1;
zval_unicode_to_string(*stuff TSRMLS_CC);
} else {
is_unicode = 0;
}
#else
if (SUCCESS == zend_hash_find(_SERVER, "REQUEST_URI", sizeof("REQUEST_URI"), (void **) &stuff)) {
#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
@ -156,29 +112,14 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
#if PHP_MAJOR_VERSION >= 6
if (is_unicode) {
zval_string_to_unicode(*stuff TSRMLS_CC);
}
#endif
zend_hash_update(_SERVER, "PHAR_REQUEST_URI", sizeof("PHAR_REQUEST_URI"), (void *) &temp, sizeof(zval **), NULL);
}
}
}
if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_PHP_SELF) {
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(_SERVER, "PHP_SELF", sizeof("PHP_SELF"), (void **) &stuff TSRMLS_CC)) {
if (Z_TYPE_PP(stuff) == IS_UNICODE) {
is_unicode = 1;
zval_unicode_to_string(*stuff TSRMLS_CC);
} else {
is_unicode = 0;
}
#else
if (SUCCESS == zend_hash_find(_SERVER, "PHP_SELF", sizeof("PHP_SELF"), (void **) &stuff)) {
#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
@ -187,68 +128,34 @@ static void phar_mung_server_vars(char *fname, char *entry, int entry_len, char
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
#if PHP_MAJOR_VERSION >= 6
if (is_unicode) {
zval_string_to_unicode(*stuff TSRMLS_CC);
}
#endif
zend_hash_update(_SERVER, "PHAR_PHP_SELF", sizeof("PHAR_PHP_SELF"), (void *) &temp, sizeof(zval **), NULL);
}
}
}
if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_NAME) {
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(_SERVER, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &stuff TSRMLS_CC)) {
if (Z_TYPE_PP(stuff) == IS_UNICODE) {
is_unicode = 1;
zval_unicode_to_string(*stuff TSRMLS_CC);
} else {
is_unicode = 0;
}
#else
if (SUCCESS == zend_hash_find(_SERVER, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &stuff)) {
#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
ZVAL_STRINGL(*stuff, entry, entry_len, 1);
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
#if PHP_MAJOR_VERSION >= 6
if (is_unicode) {
zval_string_to_unicode(*stuff TSRMLS_CC);
}
#endif
zend_hash_update(_SERVER, "PHAR_SCRIPT_NAME", sizeof("PHAR_SCRIPT_NAME"), (void *) &temp, sizeof(zval **), NULL);
}
}
if (PHAR_GLOBALS->phar_SERVER_mung_list & PHAR_MUNG_SCRIPT_FILENAME) {
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(_SERVER, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &stuff TSRMLS_CC)) {
if (Z_TYPE_PP(stuff) == IS_UNICODE) {
is_unicode = 1;
zval_unicode_to_string(*stuff TSRMLS_CC);
} else {
is_unicode = 0;
}
#else
if (SUCCESS == zend_hash_find(_SERVER, "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME"), (void **) &stuff)) {
#endif
path_info = Z_STRVAL_PP(stuff);
code = Z_STRLEN_PP(stuff);
Z_STRLEN_PP(stuff) = spprintf(&(Z_STRVAL_PP(stuff)), 4096, "phar://%s%s", fname, entry);
MAKE_STD_ZVAL(temp);
ZVAL_STRINGL(temp, path_info, code, 0);
#if PHP_MAJOR_VERSION >= 6
if (is_unicode) {
zval_string_to_unicode(*stuff TSRMLS_CC);
}
#endif
zend_hash_update(_SERVER, "PHAR_SCRIPT_FILENAME", sizeof("PHAR_SCRIPT_FILENAME"), (void *) &temp, sizeof(zval **), NULL);
}
}
@ -942,11 +849,7 @@ PHP_METHOD(Phar, webPhar)
if (ext) {
++ext;
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)+1, (void **) &val TSRMLS_CC)) {
#else
if (SUCCESS == zend_hash_find(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)+1, (void **) &val)) {
#endif
switch (Z_TYPE_PP(val)) {
case IS_LONG:
if (Z_LVAL_PP(val) == PHAR_MIME_PHP || Z_LVAL_PP(val) == PHAR_MIME_PHPS) {
@ -960,11 +863,6 @@ PHP_METHOD(Phar, webPhar)
RETURN_FALSE;
}
break;
#if PHP_MAJOR_VERSION >= 6
case IS_UNICODE:
zval_unicode_to_string(*(val) TSRMLS_CC);
/* break intentionally omitted */
#endif
case IS_STRING:
mime_type = Z_STRVAL_PP(val);
code = PHAR_MIME_OTHER;
@ -1015,26 +913,12 @@ PHP_METHOD(Phar, mungServer)
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(mungvalues)); SUCCESS == zend_hash_has_more_elements(Z_ARRVAL_P(mungvalues)); zend_hash_move_forward(Z_ARRVAL_P(mungvalues))) {
zval **data = NULL;
#if PHP_MAJOR_VERSION >= 6
zval *unicopy = NULL;
#endif
if (SUCCESS != zend_hash_get_current_data(Z_ARRVAL_P(mungvalues), (void **) &data)) {
zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "unable to retrieve array value in Phar::mungServer()");
return;
}
#if PHP_MAJOR_VERSION >= 6
if (Z_TYPE_PP(data) == IS_UNICODE) {
MAKE_STD_ZVAL(unicopy);
*unicopy = **data;
zval_copy_ctor(unicopy);
INIT_PZVAL(unicopy);
zval_unicode_to_string(unicopy TSRMLS_CC);
data = &unicopy;
}
#endif
if (Z_TYPE_PP(data) != IS_STRING) {
zend_throw_exception_ex(phar_ce_PharException, 0 TSRMLS_CC, "Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME");
return;
@ -1056,11 +940,6 @@ PHP_METHOD(Phar, mungServer)
if (Z_STRLEN_PP(data) == sizeof("SCRIPT_FILENAME")-1 && !strncmp(Z_STRVAL_PP(data), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1)) {
PHAR_GLOBALS->phar_SERVER_mung_list |= PHAR_MUNG_SCRIPT_FILENAME;
}
#if PHP_MAJOR_VERSION >= 6
if (unicopy) {
zval_ptr_dtor(&unicopy);
}
#endif
}
}
/* }}} */
@ -5037,11 +4916,7 @@ PHP_METHOD(PharFileInfo, getContent)
phar_seek_efp(link, 0, SEEK_SET, 0, 0 TSRMLS_CC);
Z_TYPE_P(return_value) = IS_STRING;
#if PHP_MAJOR_VERSION >= 6
Z_STRLEN_P(return_value) = php_stream_copy_to_mem(fp, (void **) &(Z_STRVAL_P(return_value)), link->uncompressed_filesize, 0);
#else
Z_STRLEN_P(return_value) = php_stream_copy_to_mem(fp, &(Z_STRVAL_P(return_value)), link->uncompressed_filesize, 0);
#endif
if (!Z_STRVAL_P(return_value)) {
Z_STRVAL_P(return_value) = estrndup("", 0);

View File

@ -207,30 +207,19 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, char *pat
fpf = php_stream_alloc(&phar_ops, idata, NULL, mode);
php_url_free(resource);
efree(internal_file);
#if PHP_MAJOR_VERSION >= 6
if (context && context->options && phar_find_key(HASH_OF(context->options), "phar", sizeof("phar"), (void**)&pzoption TSRMLS_CC)) {
#else
if (context && context->options && zend_hash_find(HASH_OF(context->options), "phar", sizeof("phar"), (void**)&pzoption) == SUCCESS) {
#endif
pharcontext = HASH_OF(*pzoption);
if (idata->internal_file->uncompressed_filesize == 0
&& idata->internal_file->compressed_filesize == 0
#if PHP_MAJOR_VERSION >= 6
&& phar_find_key(pharcontext, "compress", sizeof("compress"), (void**)&pzoption TSRMLS_CC)
#else
&& zend_hash_find(pharcontext, "compress", sizeof("compress"), (void**)&pzoption) == SUCCESS
#endif
&& Z_TYPE_PP(pzoption) == IS_LONG
&& (Z_LVAL_PP(pzoption) & ~PHAR_ENT_COMPRESSION_MASK) == 0
) {
idata->internal_file->flags &= ~PHAR_ENT_COMPRESSION_MASK;
idata->internal_file->flags |= Z_LVAL_PP(pzoption);
}
#if PHP_MAJOR_VERSION >= 6
if (phar_find_key(pharcontext, "metadata", sizeof("metadata"), (void**)&pzoption TSRMLS_CC)) {
#else
if (zend_hash_find(pharcontext, "metadata", sizeof("metadata"), (void**)&pzoption) == SUCCESS) {
#endif
if (idata->internal_file->metadata) {
zval_ptr_dtor(&idata->internal_file->metadata);
idata->internal_file->metadata = NULL;

View File

@ -986,11 +986,8 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, long len, int defau
len = -len;
}
user_stub = 0;
#if PHP_MAJOR_VERSION >= 6
if (!(len = php_stream_copy_to_mem(stubfile, (void **) &user_stub, len, 0)) || !user_stub) {
#else
if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
#endif
if (error) {
spprintf(error, 0, "unable to read resource to copy stub to new tar-based phar \"%s\"", phar->fname);
}

View File

@ -603,11 +603,7 @@ foundit:
php_stream_filter_append(&fp->readfilters, filter);
#if PHP_MAJOR_VERSION >= 6
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
#else
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
#endif
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)");
@ -628,11 +624,7 @@ foundit:
php_stream_filter_append(&fp->readfilters, filter);
#if PHP_MAJOR_VERSION >= 6
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
#else
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
#endif
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)");
@ -643,11 +635,7 @@ foundit:
php_stream_filter_flush(filter, 1);
php_stream_filter_remove(filter, 1 TSRMLS_CC);
} else {
#if PHP_MAJOR_VERSION >= 6
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, (void **) &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
#else
if (!(entry.uncompressed_filesize = php_stream_copy_to_mem(fp, &actual_alias, entry.uncompressed_filesize, 0)) || !actual_alias) {
#endif
pefree(entry.filename, entry.is_persistent);
PHAR_ZIP_FAIL("unable to read in alias, truncated");
}
@ -1252,11 +1240,7 @@ int phar_zip_flush(phar_archive_data *phar, char *user_stub, long len, int defau
user_stub = 0;
#if PHP_MAJOR_VERSION >= 6
if (!(len = php_stream_copy_to_mem(stubfile, (void **) &user_stub, len, 0)) || !user_stub) {
#else
if (!(len = php_stream_copy_to_mem(stubfile, &user_stub, len, 0)) || !user_stub) {
#endif
if (error) {
spprintf(error, 0, "unable to read resource to copy stub to new zip-based phar \"%s\"", phar->fname);
}