summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2014-04-20 15:26:51 -0700
committerStanislav Malyshev <stas@php.net>2014-04-20 15:27:39 -0700
commit774f16318b3739e751d5a041f3601a3cf3000614 (patch)
treeffdd73973aa30c738e55fe9f5ce1c26636b2631c
parent1bca3ecacc19686d949f55cec410beea40491685 (diff)
parent5addf223d597c56638a34f9ef0061d454e748abe (diff)
downloadphp-git-774f16318b3739e751d5a041f3601a3cf3000614.tar.gz
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: Fix bug #65701: Do not use cache for file file copy
-rw-r--r--NEWS6
-rw-r--r--ext/standard/file.c2
-rw-r--r--ext/standard/tests/file/bug65701.phpt30
-rw-r--r--main/php_streams.h1
-rw-r--r--main/streams/streams.c48
5 files changed, 61 insertions, 26 deletions
diff --git a/NEWS b/NEWS
index f0316ee6e7..e0503fb3ef 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ PHP NEWS
- Core:
. Fixed bug #64604 (parse_url is inconsistent with specified port).
(Ingo Walz)
+ . Fixed bug #65701 (copy() doesn't work when destination filename is created
+ by tempnam()). (Boro Sitnikovski)
. Fixed bug #66015 (Unexpected array indexing in class's static property). (Bob)
. Added (constant) string/array dereferencing to static scalar expressions
to complete the set; now possible thanks to bug #66015 being fixed. (Bob)
@@ -18,6 +20,7 @@ PHP NEWS
height). (Gabor Buella)
. Fixed bug #67064 (Countable interface prevents using 2nd parameter
($mode) of count() function). (Bob)
+ . Fixed bug #67072 (Echoing unserialized "SplFileObject" crash). (Anatol)
- cURL:
. Fixed bug #66562 (curl_exec returns differently than curl_multi_getcontent).
@@ -59,9 +62,6 @@ PHP NEWS
- SQLite:
. Fixed bug #66967 (Updated bundled libsqlite to 3.8.4.3). (Anatol)
-- Standard:
- . Fixed bug #67072 (Echoing unserialized "SplFileObject" crash). (Anatol)
-
- Apache2 Handler SAPI:
. Fixed Apache log issue caused by APR's lack of support for %zu
(APR issue https://issues.apache.org/bugzilla/show_bug.cgi?id=56120).
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 74df6dc759..e1f24abf64 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -1668,7 +1668,7 @@ PHPAPI int php_copy_file_ctx(const char *src, const char *dest, int src_flg, php
return FAILURE;
}
- switch (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET, &dest_s, ctx)) {
+ switch (php_stream_stat_path_ex(dest, PHP_STREAM_URL_STAT_QUIET | PHP_STREAM_URL_STAT_NOCACHE, &dest_s, ctx)) {
case -1:
/* non-statable stream */
goto safe_to_copy;
diff --git a/ext/standard/tests/file/bug65701.phpt b/ext/standard/tests/file/bug65701.phpt
new file mode 100644
index 0000000000..2b1b5d491d
--- /dev/null
+++ b/ext/standard/tests/file/bug65701.phpt
@@ -0,0 +1,30 @@
+--TEST--
+Test for bug #65701: copy() doesn't work when destination filename is created by tempnam()
+--CREDITS--
+Boro Sitnikovski <buritomath@yahoo.com>
+--FILE--
+<?php
+$file_path = dirname(__FILE__) . "/bug65701/";
+
+mkdir($file_path);
+
+$src = $file_path . '/srcbug65701_file.txt';
+$dst = tempnam($file_path, 'dstbug65701_file.txt');
+
+file_put_contents($src, "Hello World");
+
+copy($src, $dst);
+var_dump(filesize($dst));
+?>
+--CLEAN--
+<?php
+$file_path = dirname(__FILE__) . "/bug65701/";
+foreach (scandir($file_path) as $file) {
+ if (strpos($file, "bug65701") !== false) {
+ unlink($file_path . $file);
+ }
+}
+rmdir($file_path);
+?>
+--EXPECT--
+int(11)
diff --git a/main/php_streams.h b/main/php_streams.h
index aa4c05c54f..d1efa71988 100644
--- a/main/php_streams.h
+++ b/main/php_streams.h
@@ -373,6 +373,7 @@ END_EXTERN_C()
/* Flags for url_stat method in wrapper ops */
#define PHP_STREAM_URL_STAT_LINK 1
#define PHP_STREAM_URL_STAT_QUIET 2
+#define PHP_STREAM_URL_STAT_NOCACHE 4
/* change the blocking mode of stream: value == 1 => blocking, value == 0 => non-blocking. */
#define PHP_STREAM_OPTION_BLOCKING 1
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 9f9661dbfd..67a151014d 100644
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -1924,16 +1924,18 @@ PHPAPI int _php_stream_stat_path(const char *path, int flags, php_stream_statbuf
const char *path_to_open = path;
int ret;
- /* Try to hit the cache first */
- if (flags & PHP_STREAM_URL_STAT_LINK) {
- if (BG(CurrentLStatFile) && strcmp(path, BG(CurrentLStatFile)) == 0) {
- memcpy(ssb, &BG(lssb), sizeof(php_stream_statbuf));
- return 0;
- }
- } else {
- if (BG(CurrentStatFile) && strcmp(path, BG(CurrentStatFile)) == 0) {
- memcpy(ssb, &BG(ssb), sizeof(php_stream_statbuf));
- return 0;
+ if (!(flags & PHP_STREAM_URL_STAT_NOCACHE)) {
+ /* Try to hit the cache first */
+ if (flags & PHP_STREAM_URL_STAT_LINK) {
+ if (BG(CurrentLStatFile) && strcmp(path, BG(CurrentLStatFile)) == 0) {
+ memcpy(ssb, &BG(lssb), sizeof(php_stream_statbuf));
+ return 0;
+ }
+ } else {
+ if (BG(CurrentStatFile) && strcmp(path, BG(CurrentStatFile)) == 0) {
+ memcpy(ssb, &BG(ssb), sizeof(php_stream_statbuf));
+ return 0;
+ }
}
}
@@ -1941,19 +1943,21 @@ PHPAPI int _php_stream_stat_path(const char *path, int flags, php_stream_statbuf
if (wrapper && wrapper->wops->url_stat) {
ret = wrapper->wops->url_stat(wrapper, path_to_open, flags, ssb, context TSRMLS_CC);
if (ret == 0) {
- /* Drop into cache */
- if (flags & PHP_STREAM_URL_STAT_LINK) {
- if (BG(CurrentLStatFile)) {
- efree(BG(CurrentLStatFile));
- }
- BG(CurrentLStatFile) = estrdup(path);
- memcpy(&BG(lssb), ssb, sizeof(php_stream_statbuf));
- } else {
- if (BG(CurrentStatFile)) {
- efree(BG(CurrentStatFile));
+ if (!(flags & PHP_STREAM_URL_STAT_NOCACHE)) {
+ /* Drop into cache */
+ if (flags & PHP_STREAM_URL_STAT_LINK) {
+ if (BG(CurrentLStatFile)) {
+ efree(BG(CurrentLStatFile));
+ }
+ BG(CurrentLStatFile) = estrdup(path);
+ memcpy(&BG(lssb), ssb, sizeof(php_stream_statbuf));
+ } else {
+ if (BG(CurrentStatFile)) {
+ efree(BG(CurrentStatFile));
+ }
+ BG(CurrentStatFile) = estrdup(path);
+ memcpy(&BG(ssb), ssb, sizeof(php_stream_statbuf));
}
- BG(CurrentStatFile) = estrdup(path);
- memcpy(&BG(ssb), ssb, sizeof(php_stream_statbuf));
}
}
return ret;