|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-03-09 22:18 UTC] jani@php.net
-Status: Open
+Status: Bogus
[2010-03-09 22:18 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 13:00:01 2025 UTC |
Description: ------------ usage of str_replace() as described below produce the expected result the first time it is called (a select box with 3 choices), but it then introduce incoherent/unstable state within PHP who cannot correctly serve any further request and producing irrelevant warnings. It would seems to me that PHP is not able to correctly create new objects after the first request as any access to "$this" produce a warning. This was reproduced with XAMPP Lite for Windows 1.7.3 and Zend Framework 1.9. I am not in position to try on linux version but will do soon and report back... Test script: --------------- <?php require_once('Zend/View.php'); require_once('Zend/Form.php'); require_once('Zend/Form/Element/Select.php'); function foo() { $form = new Zend_Form(); $element = new Zend_Form_Element_Select('selectbox', array('multiOptions' => array('group 1', 'group 2', 'group 3'))); $form->addElement($element); $form->setView(new Zend_View()); return $form; } echo str_replace('group', 'replaced', foo()); // Will introduce unstable state echo str_replace('group', 'replaced', (string)foo()); // Always working fine ?> Expected result: ---------------- It should always return this, no matter how many times we access the page: <form enctype="application/x-www-form-urlencoded" action="" method="post"><dl class="zend_form"> <dt id="selectbox-label"> </dt> <dd id="selectbox-element"> <select name="selectbox" id="selectbox"> <option value="0" label="replaced 1">replaced 1</option> <option value="1" label="replaced 2">replaced 2</option> <option value="2" label="replaced 3">replaced 3</option> </select></dd></dl></form> Actual result: -------------- The second time the page is visited, we have: <br /> <b>Warning</b>: Attempt to assign property of non-object in <b>C:\xampplite\ZendFramework\library\Zend\Form\Element.php</b> on line <b>468</b><br /> <br /> <b>Warning</b>: Attempt to assign property of non-object in <b>C:\xampplite\ZendFramework\library\Zend\Form\Element\Multi.php</b> on line <b>208</b><br /> <br /> <b>Warning</b>: Attempt to assign property of non-object in <b>C:\xampplite\ZendFramework\library\Zend\Form\Element\Multi.php</b> on line <b>209</b><br /> <br /> <b>Fatal error</b>: Uncaught exception 'Zend_Form_Exception' with message 'Zend_Form_Element requires each element to have a name' in C:\xampplite\ZendFramework\library\Zend\Form\Element.php:253 Stack trace: #0 C:\xampplite\htdocs\okpilot\htdocs\admin\news.php(9): Zend_Form_Element->__construct('selectbox', Array) #1 C:\xampplite\htdocs\okpilot\htdocs\admin\news.php(16): foo() #2 {main} thrown in <b>C:\xampplite\ZendFramework\library\Zend\Form\Element.php</b> on line <b>253</b><br />