mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
[ticket/10375] Make _tpl_load() a little leaner.
- Removed duplicate variables - Set $source_file earlier for cache checks - Fixed useless mtime check PHPBB3-10375
This commit is contained in:
parent
25aee49ca5
commit
9d5e9af54b
1 changed files with 6 additions and 19 deletions
|
@ -307,35 +307,22 @@ class phpbb_template
|
||||||
*/
|
*/
|
||||||
private function _tpl_load($handle)
|
private function _tpl_load($handle)
|
||||||
{
|
{
|
||||||
$source_file = null;
|
$source_file = $this->locator->get_source_file_for_handle($handle);
|
||||||
|
$output_file = $this->_compiled_file_for_handle($handle);
|
||||||
$compiled_path = $this->_compiled_file_for_handle($handle);
|
|
||||||
|
|
||||||
$recompile = defined('DEBUG_EXTRA') ||
|
$recompile = defined('DEBUG_EXTRA') ||
|
||||||
!file_exists($compiled_path) ||
|
!file_exists($output_file) ||
|
||||||
@filesize($compiled_path) === 0 ||
|
@filesize($output_file) === 0 ||
|
||||||
($this->config['load_tplcompile'] && @filemtime($compiled_path) < @filemtime($source_file));
|
($this->config['load_tplcompile'] && @filemtime($output_file) < @filemtime($source_file));
|
||||||
|
|
||||||
if (!$recompile && $this->config['load_tplcompile'])
|
|
||||||
{
|
|
||||||
$source_file = $this->locator->get_source_file_for_handle($handle);
|
|
||||||
$recompile = (@filemtime($compiled_path) < @filemtime($source_file)) ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recompile page if the original template is newer, otherwise load the compiled version
|
// Recompile page if the original template is newer, otherwise load the compiled version
|
||||||
if (!$recompile)
|
if (!$recompile)
|
||||||
{
|
{
|
||||||
return new phpbb_template_renderer_include($compiled_path, $this);
|
return new phpbb_template_renderer_include($output_file, $this);
|
||||||
}
|
|
||||||
|
|
||||||
if ($source_file === null)
|
|
||||||
{
|
|
||||||
$source_file = $this->locator->get_source_file_for_handle($handle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$compile = new phpbb_template_compile($this->config['tpl_allow_php']);
|
$compile = new phpbb_template_compile($this->config['tpl_allow_php']);
|
||||||
|
|
||||||
$output_file = $this->_compiled_file_for_handle($handle);
|
|
||||||
if ($compile->compile_file_to_file($source_file, $output_file) !== false)
|
if ($compile->compile_file_to_file($source_file, $output_file) !== false)
|
||||||
{
|
{
|
||||||
$renderer = new phpbb_template_renderer_include($output_file, $this);
|
$renderer = new phpbb_template_renderer_include($output_file, $this);
|
||||||
|
|
Loading…
Add table
Reference in a new issue