Commit ba318002 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
...@@ -625,20 +625,30 @@ class plugin ...@@ -625,20 +625,30 @@ class plugin
return $result; 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])) { if (isset($cache[$key])) {
return $cache[$key]; return $cache[$key];
} }
if ($forbidden === NULL) {
$forbidden = $key; $forbidden[] = $key;
} elseif ($forbidden == $key) {
die('Error : recursive dependency'); $array =
}
$array =
array_map( array_map(
function ($a) use (&$cache, $depends, $forbidden) 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); $deps = plugin::tpl_depends_of ($cache, $depends, $a, $forbidden);
if (($askmeKey = array_search('askme', $deps)) !== FALSE) { if (($askmeKey = array_search('askme', $deps)) !== FALSE) {
/* Do not flat special askme dependency */ /* Do not flat special askme dependency */
......
  • bmortier @bmortier

    mentioned in issue #1538

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

    ·

    mentioned in issue #1538

    By Côme Chilliet on 2017-09-02T15:29:51 (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