Skip to content

fetch("extends:foo.html|smarty.tpl") returns the same content over and over again #1177

Description

@JulianAtkins

Hello!

I've written a PHP script that iterates over my database content that is saved in a smarty.tpl file, which is used to generates HTML pages.

The loop looks like this:

$smarty->force_compile = true;
$smarty->setCaching(Smarty::CACHING_OFF);

foreach($databaseRows as $key => $row) {

	// Generate a temporary smarty.tpl file with the database content
	file_put_contents("smarty.tpl", "{block name=content}{strip}" . $row . "{/strip}{/block}");

	// Generate the final HTML file
	file_put_contents("final-" . $key . ".html", $smarty->fetch("extends:foo.html|smarty.tpl", $url, time());

}

The generated files (final-123.html) are all the same, the contents of the very first database row. Since the fetch() function works fine the first time, but all subsequent calls do not read the newly generated smarty.tpl but the cached file from templates_c compile directory.

This problem appeared when I installed Smarty 5.8 (the previous version was 4.3.2).

I can temporarily avoid the problem by adding a random compile id to the fetch function.

Thank you.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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