Commit ba318002 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #4840 Improving recursion dependency detection and behavior

parent 77cb53d3
......@@ -625,20 +625,30 @@ class plugin
return $result;
}
static function tpl_depends_of (&$cache, $depends, $key, $forbidden = NULL)
static function tpl_depends_of (&$cache, $depends, $key, $forbidden = array())
{
if (isset($cache[$key])) {
return $cache[$key];
}
if ($forbidden === NULL) {
$forbidden = $key;
} elseif ($forbidden == $key) {
die('Error : recursive dependency');
}
$forbidden[] = $key;
$array =
array_map(
function ($a) use (&$cache, $depends, $forbidden)
{
if (in_array($a, $forbidden)) {
msg_dialog::display(
_('Error'),
sprintf(
_('Recursive dependency in the template fields: "%1$s" cannot depend on "%2$s" as "%2$s" already depends on "%1$s"'),
$key,
$a
),
ERROR_DIALOG
);
return array();
}
$deps = plugin::tpl_depends_of ($cache, $depends, $a, $forbidden);
if (($askmeKey = array_search('askme', $deps)) !== FALSE) {
/* Do not flat special askme dependency */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment