kalle Tue, 17 Aug 2010 12:17:28 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=302386
Log:
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
Changed paths:
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/standard/file.c
U php/php-src/branches/PHP_5_3/ext/standard/file.h
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/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2010-08-17 12:14:52 UTC (rev 302385)
+++ php/php-src/branches/PHP_5_3/NEWS 2010-08-17 12:17:28 UTC (rev 302386)
@@ -9,6 +9,7 @@
- Changed deprecated ini options on startup from E_WARNING to E_DEPRECATED.
(Kalle)
+- Changed the $context parameter on copy() to actually have an effect. (Kalle)
- Fixed bug #52573 (SplFileObject::fscanf Segmentation fault). (Felipe)
- Fixed bug #52546 (pdo_dblib segmentation fault when iterating MONEY values).
Modified: php/php-src/branches/PHP_5_3/ext/standard/file.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/file.c 2010-08-17 12:14:52 UTC
(rev 302385)
+++ php/php-src/branches/PHP_5_3/ext/standard/file.c 2010-08-17 12:17:28 UTC
(rev 302386)
@@ -1694,7 +1694,7 @@
context = php_stream_context_from_zval(zcontext, 0);
- if (php_copy_file(source, target TSRMLS_CC) == SUCCESS) {
+ if (php_copy_file_ctx(source, target, 0, context TSRMLS_CC) == SUCCESS)
{
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -1702,21 +1702,31 @@
}
/* }}} */
-PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC) /* {{{ */
+/* {{{ php_copy_file
+ */
+PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC)
{
- return php_copy_file_ex(src, dest, ENFORCE_SAFE_MODE TSRMLS_CC);
+ return php_copy_file_ctx(src, dest, ENFORCE_SAFE_MODE, NULL TSRMLS_CC);
}
/* }}} */
-/* {{{ php_copy_file
+/* {{{ php_copy_file_ex
*/
PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk TSRMLS_DC)
{
+ return php_copy_file_ctx(src, dest, ENFORCE_SAFE_MODE, NULL TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ php_copy_file_ctx
+ */
+PHPAPI int php_copy_file_ctx(char *src, char *dest, int src_chk,
php_stream_context *context 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, context)) {
case -1:
/* non-statable stream */
goto safe_to_copy;
@@ -1731,7 +1741,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, context)) {
case -1:
/* non-statable stream */
goto safe_to_copy;
@@ -1781,13 +1791,13 @@
}
safe_to_copy:
- srcstream = php_stream_open_wrapper(src, "rb", src_chk | REPORT_ERRORS,
NULL);
+ srcstream = php_stream_open_wrapper_ex(src, "rb", src_chk |
REPORT_ERRORS, NULL, context);
if (!srcstream) {
return ret;
}
- deststream = php_stream_open_wrapper(dest, "wb", ENFORCE_SAFE_MODE |
REPORT_ERRORS, NULL);
+ deststream = php_stream_open_wrapper_ex(dest, "wb", ENFORCE_SAFE_MODE |
REPORT_ERRORS, NULL, context);
if (srcstream && deststream) {
ret = php_stream_copy_to_stream_ex(srcstream, deststream,
PHP_STREAM_COPY_ALL, NULL);
Modified: php/php-src/branches/PHP_5_3/ext/standard/file.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/file.h 2010-08-17 12:14:52 UTC
(rev 302385)
+++ php/php-src/branches/PHP_5_3/ext/standard/file.h 2010-08-17 12:17:28 UTC
(rev 302386)
@@ -76,6 +76,7 @@
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_ctx(char *src, char *dest, int src_chk,
php_stream_context *context 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);
Modified: php/php-src/trunk/ext/standard/basic_functions.c
===================================================================
--- php/php-src/trunk/ext/standard/basic_functions.c 2010-08-17 12:14:52 UTC
(rev 302385)
+++ php/php-src/trunk/ext/standard/basic_functions.c 2010-08-17 12:17:28 UTC
(rev 302386)
@@ -5716,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, NULL TSRMLS_CC) == SUCCESS) {
+ } else if (php_copy_file_ex(path, new_path, STREAM_DISABLE_OPEN_BASEDIR
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-17 12:14:52 UTC (rev
302385)
+++ php/php-src/trunk/ext/standard/file.c 2010-08-17 12:17:28 UTC (rev
302386)
@@ -1646,7 +1646,7 @@
context = php_stream_context_from_zval(zcontext, 0);
- if (php_copy_file_ex(source, target, 0, context TSRMLS_CC) == SUCCESS) {
+ if (php_copy_file_ctx(source, target, 0, context TSRMLS_CC) == SUCCESS)
{
RETURN_TRUE;
} else {
RETURN_FALSE;
@@ -1654,16 +1654,26 @@
}
/* }}} */
-PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC) /* {{{ */
+/* {{{ php_copy_file
+ */
+PHPAPI int php_copy_file(char *src, char *dest TSRMLS_DC)
{
- return php_copy_file_ex(src, dest, 0, NULL TSRMLS_CC);
+ return php_copy_file_ctx(src, dest, 0, NULL TSRMLS_CC);
}
/* }}} */
-/* {{{ php_copy_file
+/* {{{ php_copy_file_ex
*/
-PHPAPI int php_copy_file_ex(char *src, char *dest, int src_flg,
php_stream_context *ctx TSRMLS_DC)
+PHPAPI int php_copy_file_ex(char *src, char *dest, int src_flg TSRMLS_DC)
{
+ return php_copy_file_ctx(src, dest, 0, NULL TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ php_copy_file_ctx
+ */
+PHPAPI int php_copy_file_ctx(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;
Modified: php/php-src/trunk/ext/standard/file.h
===================================================================
--- php/php-src/trunk/ext/standard/file.h 2010-08-17 12:14:52 UTC (rev
302385)
+++ php/php-src/trunk/ext/standard/file.h 2010-08-17 12:17:28 UTC (rev
302386)
@@ -75,7 +75,8 @@
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,
php_stream_context *ctx TSRMLS_DC);
+PHPAPI int php_copy_file_ex(char *src, char *dest, int src_chk TSRMLS_DC);
+PHPAPI int php_copy_file_ctx(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);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php