Bug #64178 [Fbk->Opn]: move_uploaded_file() sometimes executes a copy followed by a move unnecessarily
| From: | jbrown at bluedroplet dot com | Date: | Sun, 17 Feb 2013 00:22:57 +0000 |
| Subject: | Bug #64178 [Fbk->Opn]: move_uploaded_file() sometimes executes a copy followed by a move unnecessarily | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-176659@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64178&edit=1
ID: 64178
User updated by: jbrown at bluedroplet dot com
Reported by: jbrown at bluedroplet dot com
Summary: move_uploaded_file() sometimes executes a copy
followed by a move unnecessarily
-Status: Feedback
+Status: Open
Type: Bug
Package: Streams related
Operating System: Ubuntu 12.10
PHP Version: 5.4.11
Block user comment: N
Private report: N
New Comment:
I used to run a transcoding server and it would fall over if a 1GB file was uploaded. Pre-resolving
the private:// URI before passing it to move_uploaded_file() would prevent this from happening as it
would issue a rename instead of a copy followed by a delete.
In general, when moving a file between stream wrappers it makes sense to attempt to resolve them
both. If they do both resolve then an rename can be issued instead of a copy followed by a delete.
If source and destination are on the same filesystem then this will be extremely cheap.
Previous Comments:
------------------------------------------------------------------------
[2013-02-15 23:14:45] cataphract@php.net
You mean copy followed by a delete? In which case, PHP just calls rename(2) and, if that fails,
moves on to copy+delete. Apart from the case where the destination is actually a file:// URL, I
don't see any situation where the copy is unnecessary and PHP could detect it. Can you
elaborate on that point?
------------------------------------------------------------------------
[2013-02-09 02:20:17] jbrown at bluedroplet dot com
Description:
------------
move_uploaded_file() executes a copy followed by a move when stream wrapper URIs are used, even the
source and destination are on the same file system
See http://drupal.org/node/1395524
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64178&edit=1