Zend Framework

Apache crashes on PHP 5.2.3 if Zend_View_Helper_FormElement is used with name 'id'

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: Next Major Release
  • Fix Version/s: None
  • Component/s: Zend_View
  • Labels:
    None

Description

Zend Framework RC 1.7 crashes Apache if you use the following code:

$form = new Zend_Form();
$form->setName('someFormName');
$form->addElement(new Zend_Form_Element_Text('id'));
^^ Crash

The problem is located in Zend_View_Helper_FormElement ~109:
// Set ID for element
if (isset($info['attribs']['id'])) { $info['id'] = (string)$info['attribs']['id']; }
}

For the code above, $info['attribs']['id'] has the value of Zend_View_Helper_FormElement and could not be casted to string.
Either patch the code part with:
if (isset($info['attribs']['id'])) {
if (is_object($info['attribs']['id']))

{ $info['id'] = $info['attribs']['id']->__toString(); }

else

{ $info['id'] = (string)$info['attribs']['id']; }

}

or disallow the use of 'id' for the name-attribute in form elements.
I supposed the bug exists in previous versions too.

Activity

Hide
Jon Whitcraft added a comment -

I just used the latest svn branch with the exact same code that you posted and here is what it output in the browser

<form id="someFormName" enctype="application/x-www-form-urlencoded" action="" method="post"><dl class="zend_form">
<dt>&nbsp;</dt>
<dd>
<input type="text" name="id" id="id" value=""></dd></dl></form>

Can you provide information to help support this case?

Show
Jon Whitcraft added a comment - I just used the latest svn branch with the exact same code that you posted and here is what it output in the browser
<form id="someFormName" enctype="application/x-www-form-urlencoded" action="" method="post"><dl class="zend_form">
<dt>&nbsp;</dt>
<dd>
<input type="text" name="id" id="id" value=""></dd></dl></form>
Can you provide information to help support this case?
Hide
Christopher Klein added a comment -

The code above now works - don't ask me why Apache crashed.
BUT: The output of code is wrong:

<form id="&lt;dt&gt;&lt;/dt&gt;
&lt;dd&gt;
&lt;input type=&quot;text&quot; name=&quot;id&quot; id=&quot;id&quot; value=&quot;&quot;&gt;&lt;/dd&gt;" enctype="application/x-www-form-urlencoded" action="" method="post"><dl class="zend_form">
<dt></dt>
<dd>
<input type="text" name="id" id="id" value=""></dd></dl></form>
Show
Christopher Klein added a comment - The code above now works - don't ask me why Apache crashed. BUT: The output of code is wrong:
<form id="&lt;dt&gt;&lt;/dt&gt;
&lt;dd&gt;
&lt;input type=&quot;text&quot; name=&quot;id&quot; id=&quot;id&quot; value=&quot;&quot;&gt;&lt;/dd&gt;" enctype="application/x-www-form-urlencoded" action="" method="post"><dl class="zend_form">
<dt></dt>
<dd>
<input type="text" name="id" id="id" value=""></dd></dl></form>
Hide
Jon Whitcraft added a comment -

I just tested this against the 1.7pr release and this is what it output

ZF Version: 1.7.0PR<br />
<form id="someFormName" enctype="application/x-www-form-urlencoded" action="" method="post"><dl class="zend_form">
<dt>&nbsp;</dt>
<dd>
<input type="text" name="id" id="id" value=""></dd></dl></form>
Show
Jon Whitcraft added a comment - I just tested this against the 1.7pr release and this is what it output
ZF Version: 1.7.0PR<br />
<form id="someFormName" enctype="application/x-www-form-urlencoded" action="" method="post"><dl class="zend_form">
<dt>&nbsp;</dt>
<dd>
<input type="text" name="id" id="id" value=""></dd></dl></form>
Hide
Jon Whitcraft added a comment -

Do you have any more information on this issue? It looks like a non issue to me since it works in my testing with SVN, 1.6.2 and 1.7.0 PR.

Show
Jon Whitcraft added a comment - Do you have any more information on this issue? It looks like a non issue to me since it works in my testing with SVN, 1.6.2 and 1.7.0 PR.
Hide
Jon Whitcraft added a comment -

I can not reproduce this issue. You can re-open this issue if you can provide more information and some sample code on how to reproduce it against the current release branch or the latest svn branch.

Show
Jon Whitcraft added a comment - I can not reproduce this issue. You can re-open this issue if you can provide more information and some sample code on how to reproduce it against the current release branch or the latest svn branch.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: