LStemplate: detect and stop template displaying loop

This commit is contained in:
Benjamin Renard 2021-10-25 17:48:58 +02:00
parent c9b2341dbf
commit 06071f2f5f

View file

@ -90,6 +90,9 @@ class LStemplate extends LSlog_staticLoggerClass {
'top.tpl', 'bottom.tpl',
);
// Keep trace of last displayed template (for loop detection)
private static $last_displayed_template = null;
/**
* Start LStemplate
*
@ -419,6 +422,12 @@ class LStemplate extends LSlog_staticLoggerClass {
// Trigger displaying event
self :: fireEvent('displaying');
// Handle loop detection
if (self :: $last_displayed_template == $template) {
self :: log_error("display($template): loop detected, stop");
return;
}
try {
self :: assignCommonVars();
self :: $_smarty -> display("ls:$template");