svn: /php/php-src/trunk/ext/standard/ basic_functions.c file.c file.h
| From: | Kalle Sommer Nielsen | Date: | Mon, 16 Aug 2010 21:56:35 +0000 |
| Subject: | svn: /php/php-src/trunk/ext/standard/ basic_functions.c file.c file.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-63304@lists.php.net to get a copy of this message | ||
kalle Mon, 16 Aug 2010 21:56:35 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=302376
Log:
Fixed the context parameter on copy() to actually have an effect
# After looking at the logs, Jani did a bad merge into 5.3, so that
# the context parameter sent to copy() actually isn't used at all. This
# relatively simple patch fixes that for trunk.
#
# See FR #42965
# internals:
# This changes the php_copy_*() decls to contain an additional parameter for stream contexts
Bug: http://bugs.php.net/42965 (Open) copy() should support
context parameters for URLs
Changed paths:
U php/php-src/trunk/ext/standard/basic_functions.c
U php/php-src/trunk/ext/standard/file.c
U php/php-src/trunk/ext/standard/file.h
Modified: php/php-src/trunk/ext/standard/basic_functions.c
===================================================================
--- php/php-src/trunk/ext/standard/basic_functions.c 2010-08-16 21:43:19 UTC (rev 302375)
+++ php/php-src/trunk/ext/standard/basic_functions.c 2010-08-16 21:56:35 UTC (rev 302376)
@@ -1206,6 +1206,7 @@
ZEND_BEGIN_ARG_INFO(arginfo_copy, 0)
ZEND_ARG_INFO(0, source_file)
ZEND_ARG_INFO(0, destination_file)
+ ZEND_ARG_INFO(0, context)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_fread, 0)
@@ -5715,7 +5716,7 @@
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
}
#endif
- } else if (php_copy_file_ex(path, new_path, STREAM_DISABLE_OPEN_BASEDIR TSRMLS_CC) == SUCCESS) {
+ } else if (php_copy_file_ex(path, new_path, STREAM_DISABLE_OPEN_BASEDIR, NULL TSRMLS_CC) ==
SUCCESS) {
VCWD_UNLINK(path);
successful = 1;
}
Modified: php/php-src/trunk/ext/standard/file.c
===================================================================
--- php/php-src/trunk/ext/standard/file.c 2010-08-16 21:43:19 UTC (rev 302375)
+++ php/php-src/trunk/ext/standard/file.c 2010-08-16 21:56:35 UTC (rev 302376)
@@ -1646,7 +1646,7 @@
context = php_stream_context_from_zval(zcontext, 0);
- if (php_copy_file(source, target TSRMLS_CC) == SUCCESS) {
+ if (php_copy_file_ex(source, target, 0, context TSRMLS_CC) == SUCCESS) {
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -1656,19 +1656,19 @@
PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC) /* {{{ */
{
- return php_copy_file_ex(src, dest, 0 TSRMLS_CC);
+ return php_copy_file_ex(src, dest, 0, NULL TSRMLS_CC);
}
/* }}} */
/* {{{ php_copy_file
*/
-PHPAPI int php_copy_file_ex(char *src, char *dest, int src_flg TSRMLS_DC)
+PHPAPI int php_copy_file_ex(char *src, char *dest, int src_flg, php_stream_context *ctx TSRMLS_DC)
{
php_stream *srcstream = NULL, *deststream = NULL;
int ret = FAILURE;
php_stream_statbuf src_s, dest_s;
- switch (php_stream_stat_path_ex(src, 0, &src_s, NULL)) {
+ switch (php_stream_stat_path_ex(src, 0, &src_s, ctx)) {
case -1:
/* non-statable stream */
goto safe_to_copy;
@@ -1683,7 +1683,7 @@
return FAILURE;
}
- switch (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, &dest_s, NULL)) {
+ switch (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, &dest_s, ctx)) {
case -1:
/* non-statable stream */
goto safe_to_copy;
@@ -1733,13 +1733,13 @@
}
safe_to_copy:
- srcstream = php_stream_open_wrapper(src, "rb", src_flg | REPORT_ERRORS, NULL);
+ srcstream = php_stream_open_wrapper_ex(src, "rb", src_flg | REPORT_ERRORS, NULL, ctx);
if (!srcstream) {
return ret;
}
- deststream = php_stream_open_wrapper(dest, "wb", REPORT_ERRORS, NULL);
+ deststream = php_stream_open_wrapper_ex(dest, "wb", REPORT_ERRORS, NULL, ctx);
if (srcstream && deststream) {
ret = php_stream_copy_to_stream_ex(srcstream, deststream, PHP_STREAM_COPY_ALL, NULL);
Modified: php/php-src/trunk/ext/standard/file.h
===================================================================
--- php/php-src/trunk/ext/standard/file.h 2010-08-16 21:43:19 UTC (rev 302375)
+++ php/php-src/trunk/ext/standard/file.h 2010-08-16 21:56:35 UTC (rev 302376)
@@ -75,7 +75,7 @@
PHPAPI int php_le_stream_context(void);
PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC);
PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC);
-PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk TSRMLS_DC);
+PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk, php_stream_context *ctx TSRMLS_DC);
PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC);
PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC);
PHPAPI void php_fgetcsv(php_stream *stream, char delimiter, char enclosure, char escape_char,
size_t buf_len, char *buf, zval *return_value TSRMLS_DC);