ZF-11941: Segmentation fault rendering Zend_Form after condition check
In certain versions of PHP (tested in 5.3.8) and Zend_Framework (tested in 1.11.11), when performing a conditional check on echoing a form instance from Zend_View, it causes PHP to crash.
<?php require('Zend/Loader/Autoloader.php'); Zend_Loader_Autoloader::getInstance(); $view = new Zend_View(); $form = new Zend_Form; $form->setView($view); $input = new Zend_Form_Element_Text('input'); $input->setLabel('Input') ->setRequired(); $form->addElement($input); $view->form = $form; echo ($view->form)? $view->form : 'nothing';
If I change the last line to the following, it works without failing:
echo ($view->form)? (string) $view->form : 'nothing';
The segmentation fault occurs after the form has rendered in the shutdown phase of PHP.
Any ideas why? I can work around it as described, but it took me a while to track this down!