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

Fixes #4840 Improving recursion dependency detection and behavior

Showing with 17 additions and 7 deletions
+17 -7
......@@ -773,20 +773,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');
}
$array =
$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 */
......
  • bmortier @bmortier

    mentioned in issue #1538

    By Côme Chilliet on 2017-09-02T15:29:50 (imported from GitLab)

    ·

    mentioned in issue #1538

    By Côme Chilliet on 2017-09-02T15:29:50 (imported from GitLab)

    Toggle commit list
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