fix formula cache issue

This commit is contained in:
yuri
2019-03-26 10:22:42 +02:00
parent ef5f048343
commit 122ee3e259
2 changed files with 15 additions and 7 deletions
+12 -4
View File
@@ -1,4 +1,4 @@
<?php
<?php
/************************************************************************
* This file is part of EspoCRM.
*
@@ -39,11 +39,14 @@ class Evaluator
private $parser;
private $attributeFetcher;
private $parsedHash;
public function __construct($container = null, array $functionClassNameMap = array(), array $parsedHash = array())
{
$this->functionFactory = new \Espo\Core\Formula\FunctionFactory($container, $functionClassNameMap);
$this->attributeFetcher = new AttributeFetcher();
$this->functionFactory = new \Espo\Core\Formula\FunctionFactory($container, $this->attributeFetcher, $functionClassNameMap);
$this->formula = new \Espo\Core\Formula\Formula($this->functionFactory);
$this->parser = new \Espo\Core\Formula\Parser();
$this->parsedHash = array();
@@ -61,6 +64,11 @@ class Evaluator
if (!$item || !($item instanceof \StdClass)) {
throw new Error();
}
return $this->formula->process($item, $entity, $variables);
$result = $this->formula->process($item, $entity, $variables);
$this->attributeFetcher->resetRuntimeCache();
return $result;
}
}
}
@@ -1,4 +1,4 @@
<?php
<?php
/************************************************************************
* This file is part of EspoCRM.
*
@@ -38,10 +38,10 @@ class FunctionFactory
private $classNameMap;
public function __construct($container, $classNameMap = null)
public function __construct($container, AttributeFetcher $attributeFetcher, $classNameMap = null)
{
$this->container = $container;
$this->attributeFetcher = new AttributeFetcher();
$this->attributeFetcher = $attributeFetcher;
$this->classNameMap = $classNameMap;
}