I wrote the following peice of code to localize the problem. It executes getRender 100 times and groups result string length. output examples: Array ( [510] => 100 ) Array ( [510] => 93 [0] => 7 ) Array ( [510] => 99 [0] => 1 ) Array ( [510] => 87 [0] => 13 ) ... etc
so, sometimes getRender returns empty string with the same params
$vars = array(
'title' => 'title1',
'html' => '<div>test</div>',
'id' => 'video0',
'first' => 1,
);
$view = $this->getDI()->get('view');
$variants = [];
for ($i=0; $i < 100; $i++)
{
$view->setVars($vars);
$html = $view->getRender('article', 'video', $vars);
$idx = mb_strlen( $html );
if ( !isset($variants[$idx]) )
{
$variants[$idx] = 1;
} else {
$variants[$idx] = $variants[$idx] + 1;
};
};
print_r($variants);
view service initialization:
$view = new \Phalcon\Mvc\View();
$config = $di->get('config');
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines(array(
'.volt' => function ($view, $di) use ($config) {
$volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
$volt->setOptions(array(
'compiledPath' => $config->application->cacheDir,
'compiledSeparator' => '_',
'compileAlways' => $config->alwaysCompileTemplates,
));
\fx\view\FunctionsRegistrar::register($volt->getCompiler());
return $volt;
},
));
return $view;
We tried to change phalcon version from 2.0.13 to latest with no effect.