rename() function didn't work with /tmp dir
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
php |
Unknown
|
Unknown
|
|||
php5 (Ubuntu) |
Triaged
|
Wishlist
|
Unassigned |
Bug Description
Binary package hint: php5
I got a error message trying rename a dir from DOCUMENT_ROOT to /tmp/ dir.
Example:
rename(
return this Fatal error message ( yes, it talk about copy() function but I called rename() ):
"The first argument to copy() function cannot be a directory."
But,
rename(
it works fine inside the same DOCUMENT_ROOT path.
My enviroment:
PHP Version 5.3.3-1ubuntu9.3
Linux rock 2.6.35-26-generic #46-Ubuntu SMP Sun Jan 30 08:10:51 UTC 2011 i686
Apache/2.2.16 (Ubuntu)
Suhosin Patch 0.9.9.1
safe_mode = off
ProblemType: Bug
DistroRelease: Ubuntu 10.10
Package: php5 5.3.3-1ubuntu9.3
ProcVersionSign
Uname: Linux 2.6.35-26-generic i686
NonfreeKernelMo
Architecture: i386
Date: Tue Feb 22 16:13:37 2011
PackageArchitec
ProcEnviron:
LANGUAGE=en_US:en
LANG=en_US.UTF-8
SHELL=/bin/bash
SourcePackage: php5
Hi Djalma! Thanks for taking the time to file this bug report and help us make Ubuntu better.
Indeed, the error message is confusing, because while you called rename, copy is complaining.
This happens because of this snippet of code:
ret = VCWD_RENAME( url_from, url_to);
if (ret == -1) { file(url_ from, url_to TSRMLS_CC) == SUCCESS) { url_from, &sb) == 0) {
#ifndef PHP_WIN32
# ifdef EXDEV
if (errno == EXDEV) {
struct stat sb;
if (php_copy_
if (VCWD_STAT(
Basically since your /tmp is a different partition than your home dir, php must emulate the low level unix rename by copying the file. The copy is failing because the source is a dir, and copy doesn't accept directories.
This is a bug, with an unclear resolution. Either rename should copy recursively the whole directory to the new device, or it should describe the problem with its own error message rather than relying on copy to do it in a confusing way.
I've forwarded the issue upstream to PHP, so I'll mark the issue as Triaged. There's nothing broken, its just not doing what we'd like it to, so I'l set status to Wishlist.