Issues

ZF-11410: Variables in global scope can be overwritten

Issue Type: Improvement Created: 2011-05-25T19:48:30.000+0000 Last Updated: 2013-02-13T14:37:07.000+0000 Status: Closed Fix version(s): Reporter: Lee Davis (leedavis81) Assignee: Frank Br├╝ckner (frosch) Tags: - Zend_Form

  • View_Helper

Related issues: Attachments:

Description

In most form element view helpers extract is being used to pull out the elements name, value, attribs etc. Although its bad practice to have variables in global scope some people still code this way. By performing an extract any variable in global scope sharing these names will get overwritten.

<pre class="highlight">
        $info = $this->_getInfo($name, $value, $attribs);
        extract($info); // name, value, attribs, options, listsep, disable, escape

Proposed solutions:

remove the extract all together and reference the values from the $info array already set (reduces memory usage too).

<pre class="highlight">
        $info = $this->_getInfo($name, $value, $attribs);

        // build the element
        if ($info['disable']) {
            // disabled; display nothing
            return  '';
        }

Comments

Posted by Rob Allen (rob) on 2011-11-11T21:07:18.000+0000

The extract() only puts variables into the scope of the current method, not into the global space.

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