I don't think twig compares cache file datetime unless you use set autoreload or debug which both are actually for template development.Normally the twig rendering engine compares the dates of the common/header.twig and its processed cache file to see whether it should update the cache with your changes.
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
system/library/template/twig.php
Code: Select all
public function render($template, $cache = false) {
// specify where to look for templates
$loader = new \Twig_Loader_Filesystem(DIR_TEMPLATE);
// initialize Twig environment
$config = array('autoescape' => false, 'auto_reload'=>true);
if ($cache) {
$config['cache'] = DIR_CACHE;
}
$this->twig = new \Twig_Environment($loader, $config);
try {
// load template
$template = $this->twig->loadTemplate($template . '.twig');
return $template->render($this->data);
} catch (Exception $e) {
trigger_error('Error: Could not load template ' . $template . '!');
exit();
}
}
Code: Select all
public function index(&$route, &$args, &$template) {
$this->log->write("ControllerEventTheme::index: route='$route' priority=1000");
// If there is a template file we render
if ($template) {
// include and register Twig auto-loader
include_once(DIR_SYSTEM . 'library/template/Twig/Autoloader.php');
Twig_Autoloader::register();
// specify where to look for templates
$loader = new \Twig_Loader_Filesystem(DIR_TEMPLATE);
$config = array('autoescape' => false, 'auto_reload'=>true);
if ($this->config->get('template_cache')) {
$config['cache'] = DIR_CACHE;
}
// initialize Twig environment
$twig = new \Twig_Environment($loader, $config);
return $twig->createTemplate($template)->render($args);
}
}
If true, whenever a template is rendered, Symfony checks first if its source code has changed since it was compiled. If it has changed, the template is compiled again automatically.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
The following options are available:
debug boolean
When set to true, the generated templates have a __toString() method that you can use to display the generated nodes (default to false).
charset string (defaults to utf-8)
The charset used by the templates.
cache string or false
An absolute path where to store the compiled templates, or false to disable caching (which is the default).
auto_reload boolean
When developing with Twig, it’s useful to recompile the template whenever the source code changes. If you don’t provide a value for the auto_reload option, it will be determined automatically based on the debug value.
strict_variables boolean
If set to false, Twig will silently ignore invalid variables (variables and or attributes/methods that do not exist) and replace them with a null value. When set to true, Twig throws an exception instead (default to false).
autoescape string
Sets the default auto-escaping strategy (name, html, js, css, url, html_attr, or a PHP callback that takes the template “filename” and returns the escaping strategy to use – the callback cannot be a function name to avoid collision with built-in escaping strategies); set it to false to disable auto-escaping. The name escaping strategy determines the escaping strategy to use for a template based on the template filename extension (this strategy does not incur any overhead at runtime as auto-escaping is done at compilation time.)
optimizations integer
A flag that indicates which optimizations to apply (default to -1 – all optimizations are enabled; set it to 0 to disable).
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
Having said that, IMHO it was a bad idea to use Twig in the first place, PHP already is a template language anyway.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
Correct. I am correctly in the wonders as to know if it is simply feasible to run a composer update with older versions of the TWIG engine towards a new TWIG engine or should it require modifications to the files mentioned above.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Hi JNeuhoff, is this safe to use your codes in the previous reply to replace my current ones? I'm a little frustrated about how this twig cache slow down my tests. (I'm using 3.0.3, btw)
Code: Select all
'auto_reload' => null,
Code: Select all
'auto_reload' => true,
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
I'm really lost with this, thank you for your ideas
Edited with what?
When you make changes don't forget first to : Refresh Ocmod modifcations and clear VQMOD cache if you use then clear Theme cache, SASS cache from Dashboard right top gear.
Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer
Good question because I used to use OC native template editor to make small changes, but since I've got this problem, OC template editor doesn't load any of the twig files. (Maybe that's a clue for finding a solution) so I edit the files using FTP with Filezilla and my code editors.
Yes, I've already tried that but problem persists.
This doesn't work for me either. This twig cache issue is the biggest confusion for me so far, and here is what I'm experiencing:letxobnav wrote: ↑Mon Jun 15, 2020 12:27 pmI just change:toCode: Select all
'auto_reload' => null,
in system/library/template/twig/environment.phpCode: Select all
'auto_reload' => true,
Scenario A:
1. use theme editor to change some twig files from Admin Theme Editor
2. save it
3. clear cache from admin panel
4. check my website and see the changes happens
5. check the same file next day from theme editor and the file goes back to the older one before I changed anything
Scenario B:
1. use an external editor to edit the twig file
2. save it and use FTP to upload
3. clear cache from admin panel
4. check my website and don't see any changes
5. to make this work I have to copy/paste the same code through Theme Editor but then I go back to Scenario A
Since the theme editor stores the source in the database.check the same file next day from theme editor and the file goes back to the older one before I changed anything
I would say that you or your host is restoring or losing database content at some interval.
Scenario B
Since you have a version of the file stored in the database (theme table) which overides the core and any modification file, file changes there will have no effect.to make this work I have to copy/paste the same code through Theme Editor
So either use the theme editor (which you should never do as it is crap) or stick to using OCMOD for all changes.
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
this is good to know! thanks for the explanation!letxobnav wrote: ↑Thu Jun 18, 2020 10:32 pmscenario A
Since the theme editor stores the source in the database.check the same file next day from theme editor and the file goes back to the older one before I changed anything
I would say that you or your host is restoring or losing database content at some interval.
Scenario B
Since you have a version of the file stored in the database (theme table) which overides the core and any modification file, file changes there will have no effect.to make this work I have to copy/paste the same code through Theme Editor
So either use the theme editor (which you should never do as it is crap) or stick to using OCMOD for all changes.
So if I use theme editor to edit a certain file, it doesn't change the .twig file directly but just saves a changed copy in database?
And if I decided to stop using Theme Editor from now on, what I should do to make it work for an external editor/FTP approach (my scenario B)?
remove the version from the theme editor.And if I decided to stop using Theme Editor from now on, what I should do to make it work for an external editor/FTP approach (my scenario B)?
If you need to keep those changes, save the source and put it in an ocmod or copy it over the core.
In the end, keep your theme table empty.
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
We don't copy over the core!letxobnav wrote: ↑Fri Jun 19, 2020 8:50 amremove the version from the theme editor.And if I decided to stop using Theme Editor from now on, what I should do to make it work for an external editor/FTP approach (my scenario B)?
If you need to keep those changes, save the source and put it in an ocmod or copy it over the core.
In the end, keep your theme table empty.
Create new event files would be an alternative solution.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
There is no We.We don't copy over the core!
Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces
“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.
'We' as an indirect term. Regardless, we don't provide solutions to override core files on the forum.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Users browsing this forum: Google [Bot], moreduff and 269 guests