Skip to content

Commit a12f6d9

Browse files
committed
Fixed the $context parameter on copy() to have an effect (approved for 5.3 by Johannes)
# To not change a PHPAPI in a point release, a new function have been added to support contexts: # php_copy_file_ctx(), php_copy_file_ex() now simply wraps to that
1 parent 0cbc4a0 commit a12f6d9

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

ext/standard/basic_functions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5716,7 +5716,7 @@ PHP_FUNCTION(move_uploaded_file)
57165716
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", strerror(errno));
57175717
}
57185718
#endif
5719-
} else if (php_copy_file_ex(path, new_path, STREAM_DISABLE_OPEN_BASEDIR, NULL TSRMLS_CC) == SUCCESS) {
5719+
} else if (php_copy_file_ex(path, new_path, STREAM_DISABLE_OPEN_BASEDIR TSRMLS_CC) == SUCCESS) {
57205720
VCWD_UNLINK(path);
57215721
successful = 1;
57225722
}

ext/standard/file.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,23 +1646,33 @@ PHP_FUNCTION(copy)
16461646

16471647
context = php_stream_context_from_zval(zcontext, 0);
16481648

1649-
if (php_copy_file_ex(source, target, 0, context TSRMLS_CC) == SUCCESS) {
1649+
if (php_copy_file_ctx(source, target, 0, context TSRMLS_CC) == SUCCESS) {
16501650
RETURN_TRUE;
16511651
} else {
16521652
RETURN_FALSE;
16531653
}
16541654
}
16551655
/* }}} */
16561656

1657-
PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC) /* {{{ */
1657+
/* {{{ php_copy_file
1658+
*/
1659+
PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC)
16581660
{
1659-
return php_copy_file_ex(src, dest, 0, NULL TSRMLS_CC);
1661+
return php_copy_file_ctx(src, dest, 0, NULL TSRMLS_CC);
16601662
}
16611663
/* }}} */
16621664

1663-
/* {{{ php_copy_file
1665+
/* {{{ php_copy_file_ex
1666+
*/
1667+
PHPAPI int php_copy_file_ex(char *src, char *dest, int src_flg TSRMLS_DC)
1668+
{
1669+
return php_copy_file_ctx(src, dest, 0, NULL TSRMLS_CC);
1670+
}
1671+
/* }}} */
1672+
1673+
/* {{{ php_copy_file_ctx
16641674
*/
1665-
PHPAPI int php_copy_file_ex(char *src, char *dest, int src_flg, php_stream_context *ctx TSRMLS_DC)
1675+
PHPAPI int php_copy_file_ctx(char *src, char *dest, int src_flg, php_stream_context *ctx TSRMLS_DC)
16661676
{
16671677
php_stream *srcstream = NULL, *deststream = NULL;
16681678
int ret = FAILURE;

ext/standard/file.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ PHP_MINIT_FUNCTION(user_streams);
7575
PHPAPI int php_le_stream_context(void);
7676
PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC);
7777
PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC);
78-
PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk, php_stream_context *ctx TSRMLS_DC);
78+
PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk TSRMLS_DC);
79+
PHPAPI int php_copy_file_ctx(char *src, char *dest, int src_chk, php_stream_context *ctx TSRMLS_DC);
7980
PHPAPI int php_mkdir_ex(char *dir, long mode, int options TSRMLS_DC);
8081
PHPAPI int php_mkdir(char *dir, long mode TSRMLS_DC);
8182
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);

0 commit comments

Comments
 (0)