Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed render crash when using inline include with a string template #651

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- modifier escape now triggers a E_USER_NOTICE when an unsupported escape type is used https://github.com/smarty-php/smarty/pull/649

### Fixed
- Fixed render crash when using inline include with a string template https://github.com/smarty-php/smarty/issues/639

## [3.1.39] - 2021-02-17

### Security
Expand Down
2 changes: 1 addition & 1 deletion libs/sysplugins/smarty_internal_template.php
Expand Up @@ -317,7 +317,7 @@ public function _subTemplateRender(
$tpl->template_resource = $template;
$tpl->cache_id = $cache_id;
$tpl->compile_id = $compile_id;
if (isset($uid)) {
if (isset($uid) && isset($tpl->compiled->file_dependency[ $uid ])) {
// for inline templates we can get all resource information from file dependency
list($filepath, $timestamp, $type) = $tpl->compiled->file_dependency[ $uid ];
$tpl->source = new Smarty_Template_Source($smarty, $filepath, $type, $filepath);
Expand Down
Expand Up @@ -324,4 +324,12 @@ public function dataTestSpacing()
array("A{include file='include_spacing3.tpl'}B\nC", "AbarB\nC", '3_Newline3', $i++),
);
}

/**
* Test Inline Include with string template
*/
public function testInlineStringInclude()
{
$this->assertEquals('include-inline', $this->smarty->fetch('inline_string_include.tpl'));
}
}
@@ -0,0 +1 @@
{include "string:include-inline" inline}