Skip to content

Commit

Permalink
Attempting to cache eval'ed options for dropdowns (etc). Cache is keyed
Browse files Browse the repository at this point in the history
by md5's of code and data, may need to figure out how to get list row
data.
  • Loading branch information
cheesegrits committed Dec 19, 2015
1 parent 0de2b53 commit dcdb9b3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions components/com_fabrik/models/element.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ class PlgFabrik_Element extends FabrikPlugin
*/
public $filterDisplayValues = array();

/**
* Cache for eval'ed options for dropdowns
* @var array
*/
protected $phpOptions = array();

/**
* Constructor
*
Expand Down Expand Up @@ -3668,6 +3674,14 @@ protected function getPhpOptions($data = array())
$data = empty($data) ? $this->getFormModel()->getData() : $data;
$pop = $w->parseMessageForPlaceHolder($pop, $data);

$key = md5($pop) . '-' . md5(serialize($data));

if (isset($this->phpOptions[$key]))
{
return $this->phpOptions[$key];
}


if (FabrikHelperHTML::isDebug())
{
$res = eval($pop);
Expand All @@ -3679,6 +3693,8 @@ protected function getPhpOptions($data = array())

FabrikWorker::logEval($res, 'Eval exception : ' . $this->element->name . '::getPhpOptions() : ' . $pop . ' : %s');

$this->phpOptions[$key] = $res;

return $res;
}

Expand Down

0 comments on commit dcdb9b3

Please sign in to comment.