Eval Populate being called 10 times

Status
Not open for further replies.

achartier

Administrator
Staff member
I was busy writing some select code for a new project and had inserted a dump call and I found that the eval populate is being called 10 times while the form is being rendered. Assuming this is true the database is being queried 10 times which seems awful excessive and unnecessary.

This is just a simple form with one dropdown element. Stick a dump in the eval populate and just return array(JHTML::_('select.option', 0, 'Please Select'));

You will see what I mean.
 
Oh, no need to test it, I know that code gets run a bunch. It's just one of those chunks of code which very few people use, which we added as a specific request for someone, so the code hasn't gotten much love since it was written.

I've had a go at caching the data, let me know if it works. Minimal testing, and it'll still get called at least twice on a form load, as the element model gets reset at some point (don't ask), so the cache will get blown away.

In list display, it's only going to run once for all rows, eg. not once per row. This is because the cache is keyed by an md5 hash of $data, and it looks like we're not picking up the row data. The existing code only gets form model data. So if your code does anything which might produce different options based on row data ... it'll take some more finagling of the code to feed row data in.

https://github.com/Fabrik/fabrik/commit/dcdb9b370b07773c82b13a91780dcbf982fd89b6

-- hugh
 
Updated from Git and it is now only being called once. This should help page loads considerably.

Thanks.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top