ZF-3457: Zend_Form_Element_Multi: _translateOption large multiOption lists

Issue Type: Bug Created: 2008-06-13T16:19:02.000+0000 Last Updated: 2008-11-13T14:10:21.000+0000 Status: Resolved Fix version(s): - 1.7.0 (17/Nov/08)

Reporter: Duck Williamson (duckwilliamson) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Form

Related issues: Attachments:


In Zend_Form_Element_Multi, the _translateOption/_translateValue take far too long to process on large lists.

Calling addElement() drastically improved when I changed nothing in the code but commenting out the if (!$this->_translateOption($option, $value)) in Zend/Form/Element/Multi.php: public function addMultiOption($option, $value = '')

As a test try making a form and calling: $form->addElement('select', 'timezone', array('label' => 'Timezone', 'value' => $timezone, 'multiOptions' => timezone_identifiers_list(), 'description' => 'Pick your timezone.'));

When I benchmarked directly around this call and nothing else using microtime() _translate made the load time about 8 seconds and with it commented the load time was about .5 seconds.


Posted by Thomas Weidner (thomas) on 2008-09-28T23:46:41.000+0000

Have you set a cache for your translations ? Have you tried this several times ?

I expect that your 8 seconds come from loading the translation data in memory from disk.

Posted by Duck Williamson (duckwilliamson) on 2008-09-29T01:21:47.000+0000

I have not set a cache (do I need to?), but instead attempted to disable translations with $form->setDisableTranslator(true); (I don't intend to have any translation on the site at all) The 8 seconds was on an old dev computer I was using, my current new computer after several attempts has an average load time (for just the form load - not the whole page) of 2.52 seconds. With the two functions edited to just return* the average time is 0.38 seconds.

*The overridden functions are as follows: protected function _translateOption($option, $value) { if (!isset($this->_translated[$option])) { $this->options[$option] = $value; $this->_translated[$option] = true; return true; } return false; }

protected function _translateValue($value) { return $value; }

Posted by Matthew Weier O'Phinney (matthew) on 2008-10-30T13:21:33.000+0000

A patch has been applied to trunk to bail early from _translateOption() if the disableTranslator flag is true. Another user has verified that this speeds operations at the same factor as reported with commenting out the call.

Posted by Matthew Weier O'Phinney (matthew) on 2008-10-30T13:22:01.000+0000

Patch committed with r12201.

Posted by Wil Sinclair (wil) on 2008-11-13T14:10:21.000+0000

Changing issues in preparation for the 1.7.0 release.

Have you found an issue?

See the Overview section for more details.


© 2006-2022 by Zend by Perforce. Made with by awesome contributors.

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