mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- improvement impement workaround for HHVM PHP incompatibillity https://github.com/facebook/hhvm/issues/4797
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
===== 3.1.28-dev===== (xx.xx.2015)
|
||||
26.07.2015
|
||||
- improvement impement workaround for HHVM PHP incompatibillity https://github.com/facebook/hhvm/issues/4797
|
||||
|
||||
25.07.2015
|
||||
- bugfix parser did hang on text starting <?something https://github.com/smarty-php/smarty/issues/74
|
||||
|
||||
|
@@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.28-dev/31';
|
||||
const SMARTY_VERSION = '3.1.28-dev/32';
|
||||
|
||||
/**
|
||||
* define variable scopes
|
||||
|
@@ -48,10 +48,11 @@ abstract class Smarty_CacheResource
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param bool $update flag if called because cache update
|
||||
*
|
||||
* @return boolean true or false if the cached content does not exist
|
||||
* @return bool true or false if the cached content does not exist
|
||||
*/
|
||||
abstract public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null);
|
||||
abstract public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, $update = false);
|
||||
|
||||
/**
|
||||
* Write the rendered template output to cache
|
||||
|
@@ -119,10 +119,11 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param bool $update flag if called because cache update
|
||||
*
|
||||
* @return boolean true or false if the cached content does not exist
|
||||
*/
|
||||
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null)
|
||||
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, $update = false)
|
||||
{
|
||||
if (!$cached) {
|
||||
$cached = $_template->cached;
|
||||
|
@@ -81,10 +81,11 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param bool $update flag if called because cache update
|
||||
*
|
||||
* @return boolean true or false if the cached content does not exist
|
||||
*/
|
||||
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null)
|
||||
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, $update = false)
|
||||
{
|
||||
if (!$cached) {
|
||||
$cached = $_template->cached;
|
||||
|
@@ -86,17 +86,21 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param Smarty_Template_Cached $cached cached object
|
||||
* @param bool $update flag if called because cache update
|
||||
*
|
||||
* @return boolean true or false if the cached content does not exist
|
||||
*/
|
||||
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null)
|
||||
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, $update = false)
|
||||
{
|
||||
/** @var Smarty_Internal_Template $_smarty_tpl
|
||||
* used in included file
|
||||
*/
|
||||
$_smarty_tpl = $_template;
|
||||
|
||||
return @include $_template->cached->filepath;
|
||||
if (strpos(phpversion(), 'hhvm') !== false) {
|
||||
return Smarty_Internal_Extension_Hhvm::includeHhvm($_template, $_template->cached->filepath);
|
||||
} else {
|
||||
return @include $_template->cached->filepath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
31
libs/sysplugins/smarty_internal_extension_hhvm.php
Normal file
31
libs/sysplugins/smarty_internal_extension_hhvm.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Extension Hhvm
|
||||
*
|
||||
* include patch for modified compiled or cached templates
|
||||
* HHVM does not check if file was modified when including same file multiple times
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
class Smarty_Internal_Extension_Hhvm
|
||||
{
|
||||
/**
|
||||
* @param \Smarty_Internal_Template $_template
|
||||
* @param string $file file name
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
static function includeHhvm(Smarty_Internal_Template $_template, $file)
|
||||
{
|
||||
$_smarty_tpl = $_template;
|
||||
$tmp_file = $_template->smarty->getCompileDir() . 'hhvm' .
|
||||
str_replace(array('.', ','), '_', uniqid(rand(), true)) . '.php';
|
||||
file_put_contents($tmp_file, file_get_contents($file));
|
||||
$result = @include $tmp_file;
|
||||
@unlink($tmp_file);
|
||||
return $result;
|
||||
}
|
||||
}
|
@@ -291,7 +291,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
$this->properties['tpl_function'] = $this->parent->properties['tpl_function'];
|
||||
}
|
||||
if (!$this->cached->processed) {
|
||||
$this->cached->process($this);
|
||||
$this->cached->process($this, true);
|
||||
}
|
||||
$this->smarty->compile_check = $compile_check;
|
||||
$content = $this->getRenderedTemplateCode();
|
||||
|
@@ -210,10 +210,11 @@ class Smarty_Template_Cached
|
||||
* Process cached template
|
||||
*
|
||||
* @param Smarty_Internal_Template $_template template object
|
||||
* @param bool $update flag if called because cache update
|
||||
*/
|
||||
public function process(Smarty_Internal_Template $_template)
|
||||
public function process(Smarty_Internal_Template $_template, $update = false)
|
||||
{
|
||||
if ($this->handler->process($_template, $this) === false) {
|
||||
if ($this->handler->process($_template, $this, $update) === false) {
|
||||
$this->valid = false;
|
||||
}
|
||||
if ($this->valid) {
|
||||
|
@@ -176,7 +176,11 @@ class Smarty_Template_Compiled
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($_template->compiled->filepath);
|
||||
}
|
||||
include($_template->compiled->filepath);
|
||||
if (strpos(phpversion(), 'hhvm') !== false) {
|
||||
Smarty_Internal_Extension_Hhvm::includeHhvm($_template, $_template->compiled->filepath);
|
||||
} else {
|
||||
include($_template->compiled->filepath);
|
||||
}
|
||||
}
|
||||
$_template->smarty->compile_check = $compileCheck;
|
||||
} else {
|
||||
@@ -188,7 +192,11 @@ class Smarty_Template_Compiled
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($_template->compiled->filepath);
|
||||
}
|
||||
include($_template->compiled->filepath);
|
||||
if (strpos(phpversion(), 'hhvm') !== false) {
|
||||
Smarty_Internal_Extension_Hhvm::includeHhvm($_template, $_template->compiled->filepath);
|
||||
} else {
|
||||
include($_template->compiled->filepath);
|
||||
}
|
||||
$_template->smarty->compile_check = $compileCheck;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user