--- embedaddon/php/ext/phar/stream.c 2012/02/21 23:47:59 1.1.1.1 +++ embedaddon/php/ext/phar/stream.c 2014/06/15 20:03:54 1.1.1.4 @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | phar:// stream wrapper support | +----------------------------------------------------------------------+ - | Copyright (c) 2005-2012 The PHP Group | + | Copyright (c) 2005-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -207,30 +207,19 @@ static php_stream * phar_wrapper_open_url(php_stream_w 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; @@ -421,7 +410,7 @@ static int phar_stream_seek(php_stream *stream, off_t case SEEK_SET : temp = data->zero + offset; break; - default : + default: temp = 0; } if (temp > data->zero + (off_t) entry->uncompressed_filesize) { @@ -469,8 +458,11 @@ static int phar_stream_flush(php_stream *stream TSRMLS { char *error; int ret; - if (stream->mode[0] == 'w' || (stream->mode[0] == 'r' && stream->mode[1] == '+')) { - ret = phar_flush(((phar_entry_data *)stream->abstract)->phar, 0, 0, 0, &error TSRMLS_CC); + phar_entry_data *data = (phar_entry_data *) stream->abstract; + + if (data->internal_file->is_modified) { + data->internal_file->timestamp = time(0); + ret = phar_flush(data->phar, 0, 0, 0, &error TSRMLS_CC); if (error) { php_stream_wrapper_log_error(stream->wrapper, REPORT_ERRORS TSRMLS_CC, "%s", error); efree(error);