Issues

ZF-9261: Error setting options to Zend_File_Transfer_Adapter_Abstract

Issue Type: Bug Created: 2010-02-25T06:12:28.000+0000 Last Updated: 2010-02-25T22:49:41.000+0000 Status: Resolved Fix version(s): - 1.10.3 (01/Apr/10)

Reporter: Hristo Angelov (hedonism) Assignee: Thomas Weidner (thomas) Tags: - Zend_File_Transfer

Related issues: - ZF-9159

Attachments:

Description

Hi there,

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

<pre class="highlight">
    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:

<pre class="highlight">
...
        $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:

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

Comments

Posted by Ramon Henrique Ornelas (ramon) on 2010-02-25T07:49:10.000+0000

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

Posted by Thomas Weidner (thomas) on 2010-02-25T12:18:34.000+0000

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.

Posted by Hristo Angelov (hedonism) on 2010-02-25T22:49:36.000+0000

Hi there,

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

Thank you for your response.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts