Issues

ZF-11635: Zend_Filter_File_Rename does not keep the original filename if a target directory was provided

Description

According to http://framework.zend.com/manual/en/…, when supplying a directory in the "source" argument (whether as an argument or inside an array), the original filename should be kept. However, it is not kept, and is saved with the following example's pattern: "phpX34d".

Calling $adapter->getFileName() inside the addition of the rename filter (in order to append the original file name to the directory) retrieves the entire path of where the file will be saved prior to the filtering (as the filter is not yet applied) which is something like "/tmp/originalFileName.jpg".

The above refers to a linux file system. Haven't checked this behavior under a Windows file system.

Comments

Please provide an reproduceable example of your problem.

Note: It is a difference if you call methods prior receiving/validation/filtering or afterwards. The values you get can differ in such a case.

Closing as incomplete since there is no response since several days

Feel free to reopen as soon as you give an example of your problem by code

I think I can shed some light on this. The reporter was probably led to believe this was occurring by a poorly formed exception message:


if (file_exists($file['target'])) {
    require_once 'Zend/Filter/Exception.php';
    throw new Zend_Filter_Exception(sprintf("File '%s' could not be renamed. It already exists.", $value));
}

This should probably sprintf the $file['target'] or at least include it additionally to make clear that /tmp/phpXXXX could not be renamed to $file['target']