Skip to content

Smarty is not compatible with PHP 8.0 #605

@ildar-aim

Description

@ildar-aim

https://github.com/php/php-src/blob/php-8.0.0beta1/UPGRADING

For example, this patch causes a fatal error

diff --git a/demo/templates/index.tpl b/demo/templates/index.tpl
index 1fbb6d3..291c3fa 100644
--- a/demo/templates/index.tpl
+++ b/demo/templates/index.tpl
@@ -1,6 +1,10 @@
 {config_load file="test.conf" section="setup"}
 {include file="header.tpl" title=foo}
 
+
+{if $smarty.const.TEST}
+{$smarty.const.TEST}
+{/if}
 <PRE>
 
 {* bold and title are read from the config file *}

Fatal error: Uncaught Error: Undefined constant "TEST" in public_html/smarty/demo/templates_c/234d0264d74c0efb651cf2c28d8975810c02182d_0.file.index.tpl.cache.php:35

Stack trace:
#0 public_html/smarty/demo/templates_c/234d0264d74c0efb651cf2c28d8975810c02182d_0.file.index.tpl.cache.php(35): constant('TEST')
#1 public_html/smarty/libs/sysplugins/smarty_template_resource_base.php(123): content_5f32594c42fb41_62206325(Object(Smarty_Internal_Template))
#2 public_html/smarty/libs/sysplugins/smarty_template_compiled.php(114): Smarty_Template_Resource_Base-&gt;getRenderedTemplateCode(Object(Smarty_Internal_Template))
#3 public_html/smarty/libs/sysplugins/smarty_internal_runtime_updatecache.php(38): Smarty_Template_Compiled-&gt;render(Object(Smarty_Internal_Template))
#4 public_html/smarty/libs/sysplugins/smarty_template_cached.php(143): Smarty_Internal_Runtime_UpdateCache-&gt;updateCache(Object(Smarty_Template_Cached), Object(Smarty_Internal_Template), f#5 public_html/smarty/libs/sysplugins/smarty_internal_template.php(211): Smarty_Template_Cached-&gt;render(Object(Smarty_Internal_Template), false)
#6 public_html/smarty/libs/sysplugins/smarty_internal_templatebase.php(232): Smarty_Internal_Template-&gt;render(false, 1)
#7 public_html/smarty/libs/sysplugins/smarty_internal_templatebase.php(134): Smarty_Internal_TemplateBase-&gt;_execute(Object(Smarty_Internal_Template), NULL, NULL, NULL, 1)
#8 public_html/smarty/demo/index.php(36): Smarty_Internal_TemplateBase-&gt;display('index.tpl')
#9 {main}

due to
https://github.com/php/php-src/blob/php-8.0.0beta1/UPGRADING

The code like this should not be used

<?php if (@constant('TEST')) {
echo @constant('TEST');?>

<?php }?>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions