Zend Framework

Error setting options to Zend_File_Transfer_Adapter_Abstract

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.10.2
  • Fix Version/s: 1.10.3
  • Component/s: Zend_File_Transfer
  • Labels:
    None

Description

Hi there,

There is a little bug in the code of setOptions function.

public function setOptions($options = array(), $files = null) {
        $file = $this->_getFiles($files, false, true);

        if (is_array($options)) {
            if ($file === null) {
                $this->_options = array_merge($this->_options, $options);
            }

            foreach ($options as $name => $value) {
                foreach ($file as $key => $content) {
                    switch ($name) {
                        case 'magicFile' :
                            $this->_files[$key]['options'][$name] = (string) $value;
                            break;

                        case 'ignoreNoFile' :
                        case 'useByteString' :
                            $this->_files[$key]['options'][$name] = (boolean) $value;
                            break;

                        default:
                            require_once 'Zend/File/Transfer/Exception.php';
                            throw new Zend_File_Transfer_Exception("Unknown option: $name = $value");
                    }
                }
            }
        }

        return $this;
    }

The bug is in the line where $file is checked.
The code:

...
        $file = $this->_getFiles($files, false, true);

        if (is_array($options)) {
            if ($file === null) { //the bug
                $this->_options = array_merge($this->_options, $options);
            }
...

Here $file is never null so the options passed to the Zend_File_Transfer_Adapter_Abstract are never applied.

The solution is:

...
        if (is_array($options)) {
            if (empty($file)) { //replacing $file === null with empty($file)
                $this->_options = array_merge($this->_options, $options);
            }
...

Issue Links

Activity

Hide
Ramon Henrique Ornelas added a comment - - edited

@Hristo
Please, verify that you are using 1.10.2.
This problem has been corrected in ZF-9159.

Show
Ramon Henrique Ornelas added a comment - - edited @Hristo Please, verify that you are using 1.10.2. This problem has been corrected in ZF-9159.
Hide
Thomas Weidner added a comment -

Not reproducable within 1.10.2

The given code does not exist within that release.
Check if you are really using 1.10.2 and not another release.

Show
Thomas Weidner added a comment - Not reproducable within 1.10.2 The given code does not exist within that release. Check if you are really using 1.10.2 and not another release.
Hide
Hristo Angelov added a comment -

Hi there,

You are right, when i checkout a clean copy of 1.10.2 release everything is OK.

Thank you for your response.

Show
Hristo Angelov added a comment - Hi there, You are right, when i checkout a clean copy of 1.10.2 release everything is OK. Thank you for your response.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: