Compare commits

..

4 Commits

Author SHA1 Message Date
Simon Wisselink c02e9e135e Merge branch 'release/4.3.0' 2022-11-22 22:47:32 +01:00
Simon Wisselink 67ab8f6879 version bump 2022-11-22 22:47:30 +01:00
Simon Wisselink 773b3b4b7c Change file permissions for directories and respect umask for written files. (#828)
Fixes #548
Fixes #819
2022-11-22 22:31:54 +01:00
Hunman 613c5d691c Make SmartyCompilerException play nicer with error handler libraries (#782)
* Make SmartyCompilerException play nicer with error handler libraries

Added a new constructor, which accepts a filename and a line number too
(similar to ErrorException, except no severity parameter)
This way error handlers will display the correct file's correct line as
the source of the exception, instead of the template's line in the
core of the parser (php file)

Kept the __toString() method, but removed $source, $desc, and $template

* Revert the breaking changes
2022-11-22 21:58:13 +01:00
64 changed files with 235 additions and 161 deletions
+5 -1
View File
@@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [4.3.0] - 2022-11-22
### Added
- PHP8.2 compatibility [#775](https://github.com/smarty-php/smarty/pull/775)
@@ -13,7 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Include docs and demo in the releases [#799](https://github.com/smarty-php/smarty/issues/799)
- Using PHP functions as modifiers now triggers a deprecation notice because we will drop support for this in the next major release [#813](https://github.com/smarty-php/smarty/issues/813)
- Dropped remaining references to removed PHP-support in Smarty 4 from docs, lexer and security class. [#816](https://github.com/smarty-php/smarty/issues/816)
- Support umask when writing (template) files and set dir permissions to 777 [#548](https://github.com/smarty-php/smarty/issues/548) [#819](https://github.com/smarty-php/smarty/issues/819)
### Fixed
- Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514)
- Fixed recursion and out of memory errors when caching in complicated template set-ups using inheritance and includes [#801](https://github.com/smarty-php/smarty/pull/801)
@@ -24,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Adapt Smarty upper/lower functions to be codesafe (e.g. for Turkish locale) [#586](https://github.com/smarty-php/smarty/pull/586)
- Bug fix for underscore and limited length in template name in custom resources [#581](https://github.com/smarty-php/smarty/pull/581)
## [4.2.1] - 2022-09-14
### Security
+25
View File
@@ -46,6 +46,31 @@ class Smarty_Autoloader
*/
public static $rootClasses = array('smarty' => 'Smarty.class.php');
/**
* Registers Smarty_Autoloader backward compatible to older installations.
*
* @param bool $prepend Whether to prepend the autoloader or not.
*/
public static function registerBC($prepend = false)
{
/**
* register the class autoloader
*/
if (!defined('SMARTY_SPL_AUTOLOAD')) {
define('SMARTY_SPL_AUTOLOAD', 0);
}
if (SMARTY_SPL_AUTOLOAD
&& set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
) {
$registeredAutoLoadFunctions = spl_autoload_functions();
if (!isset($registeredAutoLoadFunctions[ 'spl_autoload' ])) {
spl_autoload_register();
}
} else {
self::register($prepend);
}
}
/**
* Registers Smarty_Autoloader as an SPL autoloader.
*
+3 -2
View File
@@ -107,7 +107,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '4.2.1';
const SMARTY_VERSION = '4.3.0';
/**
* define variable scopes
*/
@@ -139,6 +139,7 @@ class Smarty extends Smarty_Internal_TemplateBase
const DEBUG_OFF = 0;
const DEBUG_ON = 1;
const DEBUG_INDIVIDUAL = 2;
/**
* filter types
*/
@@ -779,7 +780,7 @@ class Smarty extends Smarty_Internal_TemplateBase
$this->_normalizeTemplateConfig($isConfig);
}
if ($index !== null) {
return ($dir[ $index ] ?? null);
return isset($dir[ $index ]) ? $dir[ $index ] : null;
}
return $dir;
}
+17 -7
View File
@@ -12,6 +12,7 @@
margin: 1px;
padding: 0;
}
h1 {
margin: 0;
text-align: left;
@@ -21,6 +22,7 @@
font-weight: bold;
font-size: 1.2em;
}
h2 {
background-color: #9B410E;
color: white;
@@ -29,6 +31,7 @@
padding: 2px;
border-top: 1px solid black;
}
h3 {
text-align: left;
font-weight: bold;
@@ -36,58 +39,71 @@
font-size: 0.7em;
padding: 2px;
}
body {
background: black;
}
p, table, div {
background: #f0ead8;
}
p {
margin: 0;
font-style: italic;
text-align: center;
}
table {
width: 100%;
}
th, td {
font-family: monospace;
vertical-align: top;
text-align: left;
}
td {
color: green;
}
tr:nth-child(odd) {
background-color: #eeeeee;
}
tr:nth-child(even) {
background-color: #fafafa;
}
.exectime {
font-size: 0.8em;
font-style: italic;
}
#bold div {
color: black;
font-weight: bold;
}
#blue h3 {
color: blue;
}
#normal div {
color: black;
font-weight: normal;
}
#table_assigned_vars th {
color: blue;
font-weight: bold;
}
#table_config_vars th {
color: maroon;
}
{/literal}
</style>
</head>
<body>
@@ -105,7 +121,6 @@
</span>
<br>
{/foreach}
</div>
{/if}
@@ -129,14 +144,11 @@
{$vars['attributes']|debug_print_var nofilter}
{/if}
</td>
</tr>
{/foreach}
</table>
<h2>assigned config file variables</h2>
{if NOT empty($config_vars)}
<table id="table_config_vars">
{foreach $config_vars as $vars}
<tr>
@@ -151,8 +163,6 @@
{/foreach}
</table>
{/if}
</body>
</html>
{/capture}
+1 -1
View File
@@ -20,7 +20,7 @@
* - indent_char - string (" ")
* - wrap_boundary - boolean (true)
*
* @link https://www.smarty.net/docs/en/language.function.textformat.php {textformat}
* @link https://www.smarty.net/manual/en/language.function.textformat.php {textformat}
* (Smarty online manual)
*
* @param array $params parameters
+2 -2
View File
@@ -12,7 +12,7 @@
* Purpose: print out a counter value
*
* @author Monte Ohrt <monte at ohrt dot com>
* @link https://www.smarty.net/docs/en/language.function.counter.php {counter}
* @link https://www.smarty.net/manual/en/language.function.counter.php {counter}
* (Smarty online manual)
*
* @param array $params parameters
@@ -23,7 +23,7 @@
function smarty_function_counter($params, $template)
{
static $counters = array();
$name = $params[ 'name' ] ?? 'default';
$name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default';
if (!isset($counters[ $name ])) {
$counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1);
}
+1 -1
View File
@@ -28,7 +28,7 @@
* {cycle name=row values="one,two,three" reset=true}
* {cycle name=row}
*
* @link https://www.smarty.net/docs/en/language.function.cycle.php {cycle}
* @link https://www.smarty.net/manual/en/language.function.cycle.php {cycle}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author credit to Mark Priatel <mpriatel@rogers.com>
+1 -1
View File
@@ -11,7 +11,7 @@
* Name: fetch
* Purpose: fetch file, web or ftp data and display results
*
* @link https://www.smarty.net/docs/en/language.function.fetch.php {fetch}
* @link https://www.smarty.net/manual/en/language.function.fetch.php {fetch}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
+1 -1
View File
@@ -29,7 +29,7 @@
* - assign (optional) - assign the output as an array to this variable
* - escape (optional) - escape the content (not value), defaults to true
*
* @link https://www.smarty.net/docs/en/language.function.html.checkboxes.php {html_checkboxes}
* @link https://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
* (Smarty online manual)
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
* @author credits to Monte Ohrt <monte at ohrt dot com>
+1 -1
View File
@@ -21,7 +21,7 @@
* - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
* - path_prefix - prefix for path output (optional, default empty)
*
* @link https://www.smarty.net/docs/en/language.function.html.image.php {html_image}
* @link https://www.smarty.net/manual/en/language.function.html.image.php {html_image}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author credits to Duda <duda@big.hu>
+1 -1
View File
@@ -21,7 +21,7 @@
* - id (optional) - string default not set
* - class (optional) - string default not set
*
* @link https://www.smarty.net/docs/en/language.function.html.options.php {html_image}
* @link https://www.smarty.net/manual/en/language.function.html.options.php {html_image}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
+2 -2
View File
@@ -29,7 +29,7 @@
* {html_radios values=$ids name='box' separator='<br>' output=$names}
* {html_radios values=$ids checked=$checked separator='<br>' output=$names}
*
* @link https://www.smarty.net/docs/en/language.function.html.radios.php {html_radios}
* @link https://www.smarty.net/manual/en/language.function.html.radios.php {html_radios}
* (Smarty online manual)
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
* @author credits to Monte Ohrt <monte at ohrt dot com>
@@ -156,7 +156,7 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
}
} else {
foreach ($values as $_i => $_key) {
$_val = $output[ $_i ] ?? '';
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
$_html_result[] =
smarty_function_html_radios_output(
$name,
+13 -9
View File
@@ -28,7 +28,7 @@
* - 2.0 complete rewrite for performance,
* added attributes month_names, *_id
*
* @link https://www.smarty.net/docs/en/language.function.html.select.date.php {html_select_date}
* @link https://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
* (Smarty online manual)
* @version 2.0
* @author Andrei Zmievski
@@ -179,7 +179,9 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
'd' => 'Day'
] as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName);
$$_variableName = $params[ 'time' ][ $prefix . $_elementName ] ?? date($_elementKey);
$$_variableName =
isset($time[$prefix . $_elementName]) ? $time[$prefix . $_elementName] :
date($_elementKey);
}
} elseif (isset($time[$field_array][$prefix . 'Year'])) {
// $_REQUEST given
@@ -263,8 +265,9 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
if ($year_id !== null || $all_id !== null) {
$_html_years .= ' id="' . smarty_function_escape_special_chars(
$year_id !== null ?
($year_id ?? $_name) :
($all_id ? ($all_id . $_name) : $_name)
($year_id ? $year_id : $_name) :
($all_id ? ($all_id . $_name) :
$_name)
) . '"';
}
if ($year_size) {
@@ -272,7 +275,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
}
$_html_years .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($year_empty) || isset($all_empty)) {
$_html_years .= '<option value="">' . ($year_empty ?? $all_empty) . '</option>' .
$_html_years .= '<option value="">' . (isset($year_empty) ? $year_empty : $all_empty) . '</option>' .
$option_separator;
}
$op = $start_year > $end_year ? -1 : 1;
@@ -297,8 +300,9 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
if ($month_id !== null || $all_id !== null) {
$_html_months .= ' id="' . smarty_function_escape_special_chars(
$month_id !== null ?
($month_id ?? $_name) :
($all_id ? ($all_id . $_name) : $_name)
($month_id ? $month_id : $_name) :
($all_id ? ($all_id . $_name) :
$_name)
) . '"';
}
if ($month_size) {
@@ -306,7 +310,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
}
$_html_months .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($month_empty) || isset($all_empty)) {
$_html_months .= '<option value="">' . ($month_empty ?? $all_empty) . '</option>' .
$_html_months .= '<option value="">' . (isset($month_empty) ? $month_empty : $all_empty) . '</option>' .
$option_separator;
}
for ($i = 1; $i <= 12; $i++) {
@@ -342,7 +346,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
}
$_html_days .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($day_empty) || isset($all_empty)) {
$_html_days .= '<option value="">' . ($day_empty ?? $all_empty) . '</option>' .
$_html_days .= '<option value="">' . (isset($day_empty) ? $day_empty : $all_empty) . '</option>' .
$option_separator;
}
for ($i = 1; $i <= 31; $i++) {
+19 -13
View File
@@ -11,7 +11,7 @@
* Name: html_select_time
* Purpose: Prints the dropdowns for time selection
*
* @link https://www.smarty.net/docs/en/language.function.html.select.time.php {html_select_time}
* @link https://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
* (Smarty online manual)
* @author Roberto Berto <roberto@berto.net>
* @author Monte Ohrt <monte AT ohrt DOT com>
@@ -147,7 +147,9 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
's' => 'Second'
) as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName);
$$_variableName = $params[ 'time' ][ $prefix . $_elementName ] ?? date($_elementKey);
$$_variableName =
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
date($_elementKey);
}
$_meridian =
isset($params[ 'time' ][ $prefix . 'Meridian' ]) ? (' ' . $params[ 'time' ][ $prefix . 'Meridian' ]) :
@@ -197,7 +199,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
if ($hour_id !== null || $all_id !== null) {
$_html_hours .= ' id="' .
smarty_function_escape_special_chars(
$hour_id !== null ? ($hour_id ?? $_name) :
$hour_id !== null ? ($hour_id ? $hour_id : $_name) :
($all_id ? ($all_id . $_name) : $_name)
) . '"';
}
@@ -206,7 +208,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
}
$_html_hours .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($hour_empty) || isset($all_empty)) {
$_html_hours .= '<option value="">' . ($hour_empty ?? $all_empty) . '</option>' .
$_html_hours .= '<option value="">' . (isset($hour_empty) ? $hour_empty : $all_empty) . '</option>' .
$option_separator;
}
$start = $use_24_hours ? 0 : 1;
@@ -239,8 +241,9 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
if ($minute_id !== null || $all_id !== null) {
$_html_minutes .= ' id="' . smarty_function_escape_special_chars(
$minute_id !== null ?
($minute_id ?? $_name) :
($all_id ? ($all_id . $_name) : $_name)
($minute_id ? $minute_id : $_name) :
($all_id ? ($all_id . $_name) :
$_name)
) . '"';
}
if ($minute_size) {
@@ -248,7 +251,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
}
$_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($minute_empty) || isset($all_empty)) {
$_html_minutes .= '<option value="">' . ($minute_empty ?? $all_empty) . '</option>' .
$_html_minutes .= '<option value="">' . (isset($minute_empty) ? $minute_empty : $all_empty) . '</option>' .
$option_separator;
}
$selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
@@ -276,8 +279,9 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
if ($second_id !== null || $all_id !== null) {
$_html_seconds .= ' id="' . smarty_function_escape_special_chars(
$second_id !== null ?
($second_id ?? $_name) :
($all_id ? ($all_id . $_name) : $_name)
($second_id ? $second_id : $_name) :
($all_id ? ($all_id . $_name) :
$_name)
) . '"';
}
if ($second_size) {
@@ -285,7 +289,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
}
$_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($second_empty) || isset($all_empty)) {
$_html_seconds .= '<option value="">' . ($second_empty ?? $all_empty) . '</option>' .
$_html_seconds .= '<option value="">' . (isset($second_empty) ? $second_empty : $all_empty) . '</option>' .
$option_separator;
}
$selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
@@ -313,8 +317,10 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
if ($meridian_id !== null || $all_id !== null) {
$_html_meridian .= ' id="' . smarty_function_escape_special_chars(
$meridian_id !== null ?
($meridian_id ?? $_name) :
($all_id ? ($all_id . $_name) : $_name)
($meridian_id ? $meridian_id :
$_name) :
($all_id ? ($all_id . $_name) :
$_name)
) . '"';
}
if ($meridian_size) {
@@ -322,7 +328,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
}
$_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($meridian_empty) || isset($all_empty)) {
$_html_meridian .= '<option value="">' . ($meridian_empty ?? $all_empty) .
$_html_meridian .= '<option value="">' . (isset($meridian_empty) ? $meridian_empty : $all_empty) .
'</option>' . $option_separator;
}
$_html_meridian .= '<option value="am"' . ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') .
+1 -1
View File
@@ -38,7 +38,7 @@
* @author credit to Messju Mohr <messju at lammfellpuschen dot de>
* @author credit to boots <boots dot smarty at yahoo dot com>
* @version 1.1
* @link https://www.smarty.net/docs/en/language.function.html.table.php {html_table}
* @link https://www.smarty.net/manual/en/language.function.html.table.php {html_table}
* (Smarty online manual)
*
* @param array $params parameters
+1 -1
View File
@@ -36,7 +36,7 @@
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
* {mailto address="me@domain.com" extra='class="mailto"'}
*
* @link https://www.smarty.net/docs/en/language.function.mailto.php {mailto}
* @link https://www.smarty.net/manual/en/language.function.mailto.php {mailto}
* (Smarty online manual)
* @version 1.2
* @author Monte Ohrt <monte at ohrt dot com>
+27 -27
View File
@@ -12,7 +12,7 @@
* Name: math
* Purpose: handle math computations in template
*
* @link https://www.smarty.net/docs/en/language.function.math.php {math}
* @link https://www.smarty.net/manual/en/language.function.math.php {math}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
@@ -25,35 +25,35 @@ function smarty_function_math($params, $template)
{
static $_allowed_funcs =
array(
'int' => true,
'abs' => true,
'ceil' => true,
'acos' => true,
'int' => true,
'abs' => true,
'ceil' => true,
'acos' => true,
'acosh' => true,
'cos' => true,
'cosh' => true,
'deg2rad' => true,
'rad2deg' => true,
'exp' => true,
'floor' => true,
'log' => true,
'log10' => true,
'max' => true,
'min' => true,
'pi' => true,
'pow' => true,
'rand' => true,
'round' => true,
'asin' => true,
'cos' => true,
'cosh' => true,
'deg2rad' => true,
'rad2deg' => true,
'exp' => true,
'floor' => true,
'log' => true,
'log10' => true,
'max' => true,
'min' => true,
'pi' => true,
'pow' => true,
'rand' => true,
'round' => true,
'asin' => true,
'asinh' => true,
'sin' => true,
'sinh' => true,
'sqrt' => true,
'srand' => true,
'atan' => true,
'sin' => true,
'sinh' => true,
'sqrt' => true,
'srand' => true,
'atan' => true,
'atanh' => true,
'tan' => true,
'tanh' => true
'tan' => true,
'tanh' => true
);
// be sure equation parameter is present
+1 -2
View File
@@ -15,8 +15,7 @@
* - format: strftime format for output
* - default_date: default date if $string is empty
*
* @link https://www.smarty.net/docs/en/language.modifier.date.format.php date_format
* (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input date string
+2 -2
View File
@@ -17,7 +17,7 @@
* @param string $string input string
* @param string $esc_type escape type
* @param string $char_set character set, used for htmlspecialchars() or htmlentities()
* @param boolean $double_encode encode already encoded entities again, used for htmlspecialchars() or htmlentities()
* @param boolean $double_encode encode already encoded entitites again, used for htmlspecialchars() or htmlentities()
*
* @return string escaped input string
*/
@@ -25,10 +25,10 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
{
static $is_loaded_1 = false;
static $is_loaded_2 = false;
if (!$char_set) {
$char_set = Smarty::$_CHARSET;
}
$string = (string)$string;
switch ($esc_type) {
+1 -1
View File
@@ -11,7 +11,7 @@
* Name: regex_replace
* Purpose: regular expression search/replace
*
* @link https://www.smarty.net/docs/en/language.modifier.regex.replace.php
* @link https://www.smarty.net/manual/en/language.modifier.regex.replace.php
* regex_replace (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
+1 -2
View File
@@ -11,8 +11,7 @@
* Name: replace
* Purpose: simple search/replace
*
* @link https://www.smarty.net/docs/en/language.modifier.replace.php replace
* (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews
*
+1 -2
View File
@@ -11,8 +11,7 @@
* Name: spacify
* Purpose: add spaces between characters in a string
*
* @link https://www.smarty.net/docs/en/language.modifier.spacify.php spacify
* (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input string
+1 -2
View File
@@ -13,8 +13,7 @@
* optionally splitting in the middle of a word, and
* appending the $etc string or inserting $etc into the middle.
*
* @link https://www.smarty.net/docs/en/language.modifier.truncate.php truncate
* (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input string
+1 -1
View File
@@ -14,7 +14,7 @@
* Input: string to catenate
* Example: {$var|cat:"foo"}
*
* @link https://www.smarty.net/docs/en/language.modifier.cat.php cat
* @link https://www.smarty.net/manual/en/language.modifier.cat.php cat
* (Smarty online manual)
* @author Uwe Tews
*
@@ -11,8 +11,8 @@
* Name: count_characters
* Purpose: count the number of characters in a text
*
* @link https://www.smarty.net/docs/en/language.modifier.count.characters.php count_characters
* (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
* manual)
* @author Uwe Tews
*
* @param array $params parameters
@@ -11,7 +11,7 @@
* Name: count_paragraphs
* Purpose: count the number of paragraphs in a text
*
* @link https://www.smarty.net/docs/en/language.modifier.count.paragraphs.php
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* count_paragraphs (Smarty online manual)
* @author Uwe Tews
*
@@ -11,7 +11,7 @@
* Name: count_sentences
* Purpose: count the number of sentences in a text
*
* @link https://www.smarty.net/docs/en/language.modifier.count.paragraphs.php
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* count_sentences (Smarty online manual)
* @author Uwe Tews
*
@@ -11,8 +11,7 @@
* Name: count_words
* Purpose: count the number of words in a text
*
* @link https://www.smarty.net/docs/en/language.modifier.count.words.php count_words
* (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
+1 -2
View File
@@ -11,8 +11,7 @@
* Name: default
* Purpose: designate default value for empty variables
*
* @link https://www.smarty.net/docs/en/language.modifier.default default
* (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
+3 -2
View File
@@ -11,8 +11,7 @@
* Name: escape
* Purpose: escape string for output
*
* @link https://www.smarty.net/docs/en/language.modifier.escape count_characters
* (Smarty online manual)
* @link https://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
* @author Rodney Rehm
*
* @param array $params parameters
@@ -42,6 +41,7 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
case 'html':
return 'htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
var_export($double_encode, true) . ')';
// no break
case 'htmlall':
if (Smarty::$_MBSTRING) {
return 'htmlentities(mb_convert_encoding((string)' . $params[ 0 ] . ', \'UTF-8\', ' .
@@ -51,6 +51,7 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
// no MBString fallback
return 'htmlentities((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
var_export($double_encode, true) . ')';
// no break
case 'url':
return 'rawurlencode((string)' . $params[ 0 ] . ')';
case 'urlpathinfo':
+1 -2
View File
@@ -11,8 +11,7 @@
* Name: indent
* Purpose: indent lines of text
*
* @link https://www.smarty.net/docs/en/language.modifier.indent.php indent
* (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
+1 -2
View File
@@ -11,8 +11,7 @@
* Name: lower
* Purpose: convert string to lowercase
*
* @link https://www.smarty.net/docs/en/language.modifier.lower.php lower
* (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews
*
@@ -11,8 +11,7 @@
* Name: string_format
* Purpose: format strings via sprintf
*
* @link https://www.smarty.net/docs/en/language.modifier.string.format.php string_format
* (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
+1 -2
View File
@@ -14,8 +14,7 @@
* Example: {$var|strip} {$var|strip:"&nbsp;"}
* Date: September 25th, 2002
*
* @link https://www.smarty.net/docs/en/language.modifier.strip.php strip
* (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
+1 -2
View File
@@ -11,8 +11,7 @@
* Name: lower
* Purpose: convert string to uppercase
*
* @link https://www.smarty.net/docs/en/language.modifier.upper.php lower
* (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
+1 -2
View File
@@ -11,8 +11,7 @@
* Name: wordwrap
* Purpose: wrap a string of text at a given length
*
* @link https://www.smarty.net/docs/en/language.modifier.wordwrap.php wordwrap
* (Smarty online manual)
* @link https://www.smarty.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
* @author Uwe Tews
*
* @param array $params parameters
@@ -26,7 +26,7 @@ function smarty_literal_compiler_param($params, $index, $default = null)
if (!preg_match('/^([\'"]?)[a-zA-Z0-9-]+(\\1)$/', $params[ $index ])) {
throw new SmartyException(
'$param[' . $index .
'] is not a literal and is thus not evaluable at compile time'
'] is not a literal and is thus not evaluatable at compile time'
);
}
$t = null;
-1
View File
@@ -63,7 +63,6 @@ if (!function_exists('smarty_mb_str_replace')) {
}
$parts = mb_split(preg_quote($search), $subject ?? "") ?: array();
// If original regex encoding was not unicode...
if(!$reg_is_unicode) {
// ...restore original regex encoding to avoid breaking the system.
@@ -117,7 +117,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
$cached->content,
$timestamp
);
$cached->timestamp = $timestamp ?? false;
$cached->timestamp = isset($timestamp) ? $timestamp : false;
$cached->exists = !!$cached->timestamp;
}
@@ -138,8 +138,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
if (!$cached) {
$cached = $_smarty_tpl->cached;
}
$content = $cached->content ?? null;
$timestamp = $cached->timestamp ?? null;
$content = $cached->content ? $cached->content : null;
$timestamp = $cached->timestamp ? $cached->timestamp : null;
if ($content === null || !$timestamp) {
$this->fetch(
$_smarty_tpl->cached->filepath,
@@ -187,7 +187,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
*/
public function readCachedContent(Smarty_Internal_Template $_template)
{
$content = $_template->cached->content ?? null;
$content = $_template->cached->content ? $_template->cached->content : null;
$timestamp = null;
if ($content === null) {
$timestamp = null;
@@ -102,8 +102,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
if (!$cached) {
$cached = $_smarty_tpl->cached;
}
$content = $cached->content ?? null;
$timestamp = $cached->timestamp ?? null;
$content = $cached->content ? $cached->content : null;
$timestamp = $cached->timestamp ? $cached->timestamp : null;
if ($content === null || !$timestamp) {
if (!$this->fetch(
$_smarty_tpl->cached->filepath,
@@ -148,7 +148,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
*/
public function readCachedContent(Smarty_Internal_Template $_template)
{
$content = $_template->cached->content ?? null;
$content = $_template->cached->content ? $_template->cached->content : null;
$timestamp = null;
if ($content === null) {
if (!$this->fetch(
@@ -112,7 +112,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
$_block = $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ];
unset($compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ]);
$_name = $_attr[ 'name' ];
$_assign = $_attr[ 'assign' ] ?? null;
$_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null;
unset($_attr[ 'assign' ], $_attr[ 'name' ]);
foreach ($_attr as $name => $stat) {
if ((is_bool($stat) && $stat !== false) || (!is_bool($stat) && $stat !== 'false')) {
@@ -63,9 +63,9 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args, $parameter, 'capture');
$buffer = $_attr[ 'name' ] ?? "'default'";
$assign = $_attr[ 'assign' ] ?? 'null';
$append = $_attr[ 'append' ] ?? 'null';
$buffer = isset($_attr[ 'name' ]) ? $_attr[ 'name' ] : "'default'";
$assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : 'null';
$append = isset($_attr[ 'append' ]) ? $_attr[ 'append' ] : 'null';
$compiler->_cache[ 'capture_stack' ][] = array($compiler->nocache);
// maybe nocache because of nocache variables
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
@@ -63,7 +63,7 @@ class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase
if ($this->blockType === 'Child') {
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ][ 'callsChild' ] = 'true';
}
$_assign = $_attr[ 'assign' ] ?? null;
$_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null;
$output = "<?php \n";
if (isset($_assign)) {
$output .= "ob_start();\n";
@@ -157,7 +157,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
$output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n";
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";\n?>";
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash, ob_get_clean());\n";
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash ?? '', ob_get_clean());\n";
$output .= "}\n}\n";
$output .= $compiler->cStyleComment("/ {$_funcName}_nocache ") . "\n\n";
$output .= "?>\n";
@@ -196,7 +196,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
}
$has_compiled_template = false;
if ($merge_compiled_includes) {
$c_id = $_attr[ 'compile_id' ] ?? $compiler->template->compile_id;
$c_id = isset($_attr[ 'compile_id' ]) ? $_attr[ 'compile_id' ] : $compiler->template->compile_id;
// we must observe different compile_id and caching
$t_hash = sha1($c_id . ($_caching ? '--caching' : '--nocaching'));
$compiler->smarty->allow_ambiguous_resources = true;
@@ -314,7 +314,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
} else {
$basename = $tpl->source->handler->getBasename($tpl->source);
$sourceInfo = $tpl->source->type . ':' .
($basename ?? $tpl->source->name);
($basename ? $basename : $tpl->source->name);
}
// get compiled code
$compiled_code = "<?php\n\n";
@@ -193,7 +193,7 @@ class Smarty_Internal_Configfilelexer
$this->yyTraceFILE,
"%sState push %s\n",
$this->yyTracePrompt,
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
);
}
array_push($this->_yy_stack, $this->_yy_state);
@@ -203,7 +203,7 @@ class Smarty_Internal_Configfilelexer
$this->yyTraceFILE,
"%snew State %s\n",
$this->yyTracePrompt,
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
);
}
}
@@ -215,7 +215,7 @@ class Smarty_Internal_Configfilelexer
$this->yyTraceFILE,
"%sState pop %s\n",
$this->yyTracePrompt,
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
);
}
$this->_yy_state = array_pop($this->_yy_stack);
@@ -224,7 +224,7 @@ class Smarty_Internal_Configfilelexer
$this->yyTraceFILE,
"%snew State %s\n",
$this->yyTracePrompt,
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
);
}
}
@@ -237,7 +237,7 @@ class Smarty_Internal_Configfilelexer
$this->yyTraceFILE,
"%sState set %s\n",
$this->yyTracePrompt,
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
);
}
}
+2 -3
View File
@@ -69,7 +69,6 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
public function end_template(Smarty_Internal_Template $template)
{
$key = $this->get_key($template);
if (!isset($this->template_data[ $this->index ][ $key ][ 'start_template_time' ])) return; // see internal_template L 243
$this->template_data[ $this->index ][ $key ][ 'total_time' ] +=
microtime(true) - $this->template_data[ $this->index ][ $key ][ 'start_template_time' ];
//$this->template_data[$this->index][$key]['properties'] = $template->properties;
@@ -143,7 +142,6 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
public function end_render(Smarty_Internal_Template $template)
{
$key = $this->get_key($template);
if (!isset($this->template_data[ $this->index ][ $key ][ 'start_time' ])) return; // see template_compiled L 119
$this->template_data[ $this->index ][ $key ][ 'render_time' ] +=
microtime(true) - $this->template_data[ $this->index ][ $key ][ 'start_time' ];
}
@@ -222,7 +220,8 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$debObj->debugging = false;
$debObj->debugging_ctrl = 'NONE';
$debObj->error_reporting = E_ALL & ~E_NOTICE;
$debObj->debug_tpl = $smarty->debug_tpl ?? 'file:' . dirname(__FILE__) . '/../debug.tpl';
$debObj->debug_tpl =
isset($smarty->debug_tpl) ? $smarty->debug_tpl : 'file:' . __DIR__ . '/../debug.tpl';
$debObj->registered_plugins = array();
$debObj->registered_resources = array();
$debObj->registered_filters = array();
@@ -67,7 +67,7 @@ class Smarty_Internal_Extension_Handler
public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args)
{
/* @var Smarty $data ->smarty */
$smarty = isset($data->smarty) ? $data->smarty : $data; // don't use ?? for isset here since that would need a follow-up property define in Smarty class for __get()
$smarty = isset($data->smarty) ? $data->smarty : $data;
if (!isset($smarty->ext->$name)) {
if (preg_match('/^((set|get)|(.*?))([A-Z].*)$/', $name, $match)) {
$basename = $this->upperCase($match[ 4 ]);
@@ -30,7 +30,7 @@ class Smarty_Internal_Method_GetAutoloadFilters extends Smarty_Internal_Method_S
$smarty = $obj->_getSmartyObj();
if ($type !== null) {
$this->_checkFilterType($type);
return ($smarty->autoload_filters[ $type ] ?? array());
return isset($smarty->autoload_filters[ $type ]) ? $smarty->autoload_filters[ $type ] : array();
}
return $smarty->autoload_filters;
}
@@ -40,7 +40,7 @@ class Smarty_Internal_Method_GetStreamVariable
fclose($fp);
return $_result;
}
$smarty = $data->smarty ?? $data;
$smarty = isset($data->smarty) ? $data->smarty : $data;
if ($smarty->error_unassigned) {
throw new SmartyException('Undefined stream variable "' . $variable . '"');
} else {
@@ -44,7 +44,7 @@ class Smarty_Internal_Method_RegisterFilter
{
$smarty = $obj->_getSmartyObj();
$this->_checkFilterType($type);
$name = $name ?? $this->_getFilterName($callback);
$name = isset($name) ? $name : $this->_getFilterName($callback);
if (!is_callable($callback)) {
throw new SmartyException("{$type}filter '{$name}' not callable");
}
@@ -150,7 +150,7 @@ class Smarty_Internal_Runtime_Capture
public function getBuffer(Smarty_Internal_Template $_template, $name = null)
{
if (isset($name)) {
return ($this->namedBuffer[ $name ] ?? null);
return isset($this->namedBuffer[ $name ]) ? $this->namedBuffer[ $name ] : null;
} else {
return $this->namedBuffer;
}
@@ -120,12 +120,14 @@ class Smarty_Internal_Runtime_GetIncludePath
public function getIncludePath($dirs, $file, Smarty $smarty)
{
//if (!(isset($this->_has_stream_include) ? $this->_has_stream_include : $this->_has_stream_include = false)) {
if (!($this->_has_stream_include ?? ($this->_has_stream_include = function_exists('stream_resolve_include_path')))) {
if (!(isset($this->_has_stream_include) ? $this->_has_stream_include :
$this->_has_stream_include = function_exists('stream_resolve_include_path'))
) {
$this->isNewIncludePath($smarty);
}
// try PHP include_path
foreach ($dirs as $dir) {
$dir_n = $this->number[ $dir ] ?? ($this->number[ $dir ] = $this->counter++);
$dir_n = isset($this->number[ $dir ]) ? $this->number[ $dir ] : $this->number[ $dir ] = $this->counter++;
if (isset($this->isFile[ $dir_n ][ $file ])) {
if ($this->isFile[ $dir_n ][ $file ]) {
return $this->isFile[ $dir_n ][ $file ];
@@ -151,13 +153,14 @@ class Smarty_Internal_Runtime_GetIncludePath
$this->_user_dirs[ $dir_n ] = $dir;
}
if ($this->_has_stream_include) {
$path = stream_resolve_include_path($dir . ($file ?? ''));
$path = stream_resolve_include_path($dir . (isset($file) ? $file : ''));
if ($path) {
return $this->isFile[ $dir_n ][ $file ] = $path;
}
} else {
foreach ($this->_include_dirs as $key => $_i_path) {
$path = $this->isPath[ $key ][ $dir_n ] ?? ($this->isPath[ $key ][ $dir_n ] = is_dir($_dir_path = $_i_path . $dir) ? $_dir_path : false);
$path = isset($this->isPath[ $key ][ $dir_n ]) ? $this->isPath[ $key ][ $dir_n ] :
$this->isPath[ $key ][ $dir_n ] = is_dir($_dir_path = $_i_path . $dir) ? $_dir_path : false;
if ($path === false) {
continue;
}
@@ -141,7 +141,7 @@ class Smarty_Internal_Runtime_Inheritance
*/
public function instanceBlock(Smarty_Internal_Template $tpl, $className, $name, $tplIndex = null)
{
$block = new $className($name, ($tplIndex ?? $this->tplIndex));
$block = new $className($name, isset($tplIndex) ? $tplIndex : $this->tplIndex);
if (isset($this->childRoot[ $name ])) {
$block->child = $this->childRoot[ $name ];
}
@@ -21,7 +21,8 @@ class Smarty_Internal_Runtime_TplFunction
*/
public function callTemplateFunction(Smarty_Internal_Template $tpl, $name, $params, $nocache)
{
$funcParam = $tpl->tplFunctions[ $name ] ?? ($tpl->smarty->tplFunctions[ $name ] ?? null);
$funcParam = isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
(isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : null);
if (isset($funcParam)) {
if (!$tpl->caching || ($tpl->caching && $nocache)) {
$function = $funcParam[ 'call_name' ];
@@ -83,7 +84,8 @@ class Smarty_Internal_Runtime_TplFunction
public function getTplFunction(Smarty_Internal_Template $tpl, $name = null)
{
if (isset($name)) {
return ($tpl->tplFunctions[ $name ] ?? ($tpl->smarty->tplFunctions[ $name ] ?? false));
return isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
(isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : false);
} else {
return empty($tpl->tplFunctions) ? $tpl->smarty->tplFunctions : $tpl->tplFunctions;
}
@@ -29,7 +29,6 @@ class Smarty_Internal_Runtime_WriteFile
{
$_error_reporting = error_reporting();
error_reporting($_error_reporting & ~E_NOTICE & ~E_WARNING);
$old_umask = umask(0);
$_dirpath = dirname($_filepath);
// if subdirs, create dir structure
if ($_dirpath !== '.') {
@@ -37,7 +36,7 @@ class Smarty_Internal_Runtime_WriteFile
// loop if concurrency problem occurs
// see https://bugs.php.net/bug.php?id=35326
while (!is_dir($_dirpath)) {
if (@mkdir($_dirpath, 0771, true)) {
if (@mkdir($_dirpath, 0777, true)) {
break;
}
clearstatcache();
@@ -85,8 +84,7 @@ class Smarty_Internal_Runtime_WriteFile
throw new SmartyException("unable to write file {$_filepath}");
}
// set file permissions
chmod($_filepath, 0644);
umask($old_umask);
@chmod($_filepath, 0666 & ~umask());
error_reporting($_error_reporting);
return true;
}
+5 -5
View File
@@ -222,7 +222,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
$this->smarty->ext->_cacheModify->cacheModifiedCheck(
$this->cached,
$this,
($content ?? ob_get_clean())
isset($content) ? $content : ob_get_clean()
);
} else {
if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled)
@@ -293,7 +293,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
$smarty = &$this->smarty;
$_templateId = $smarty->_getTemplateId($template, $cache_id, $compile_id, $caching, $tpl);
// recursive call ?
if (($tpl->templateId ?? $tpl->_getTemplateId()) !== $_templateId) {
if ((isset($tpl->templateId) ? $tpl->templateId : $tpl->_getTemplateId()) !== $_templateId) {
// already in template cache?
if (isset(self::$tplObjCache[ $_templateId ])) {
// copy data from cached object
@@ -538,7 +538,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
} else {
$tpl->mustCompile = !$is_valid;
$resource = $tpl->compiled;
$resource->includes = $properties[ 'includes' ] ?? array();
$resource->includes = isset($properties[ 'includes' ]) ? $properties[ 'includes' ] : array();
}
if ($is_valid) {
$resource->unifunc = $properties[ 'unifunc' ];
@@ -580,8 +580,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
*/
public function _getTemplateId()
{
return ($this->templateId ?? ($this->templateId =
$this->smarty->_getTemplateId($this->template_resource, $this->cache_id, $this->compile_id)));
return isset($this->templateId) ? $this->templateId : $this->templateId =
$this->smarty->_getTemplateId($this->template_resource, $this->cache_id, $this->compile_id);
}
/**
@@ -186,7 +186,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
} else {
// get template object
$saveVars = false;
$template = $smarty->createTemplate($template, $cache_id, $compile_id, ($parent ?? $this), false);
$template = $smarty->createTemplate($template, $cache_id, $compile_id, $parent ? $parent : $this, false);
if ($this->_objType === 1) {
// set caching in template object
$template->caching = $this->caching;
@@ -428,8 +428,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
}
$this->smarty->_debug->start_compile($this->template);
}
$this->parent_compiler = $parent_compiler ?? $this;
$nocache = $nocache ?? false;
$this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
$nocache = isset($nocache) ? $nocache : false;
if (empty($template->compiled->nocache_hash)) {
$template->compiled->nocache_hash = $this->nocache_hash;
} else {
@@ -1029,7 +1029,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
$_scope = $_scopeName;
} elseif (is_string($_scopeName)) {
$_scopeName = trim($_scopeName, '\'"');
$_scope = $validScopes[ $_scopeName ] ?? false;
$_scope = isset($validScopes[ $_scopeName ]) ? $validScopes[ $_scopeName ] : false;
} else {
$_scope = false;
}
@@ -1131,8 +1131,12 @@ abstract class Smarty_Internal_TemplateCompilerBase
echo ob_get_clean();
flush();
}
$e = new SmartyCompilerException($error_text);
$e->setLine($line);
$e = new SmartyCompilerException(
$error_text,
0,
$this->template->source->filepath,
$line
);
$e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ]));
$e->desc = $args;
$e->template = $this->template->source->filepath;
+1 -1
View File
@@ -54,7 +54,7 @@ abstract class Smarty_Resource_Custom extends Smarty_Resource
$source->timestamp = $mtime;
} else {
$this->fetch($source->name, $content, $timestamp);
$source->timestamp = $timestamp ?? false;
$source->timestamp = isset($timestamp) ? $timestamp : false;
if (isset($content)) {
$source->content = $content;
}
+1
View File
@@ -22,6 +22,7 @@
#[\AllowDynamicProperties]
class Smarty_Security
{
/**
* This is the list of template directories that are considered secure.
* $template_dir is in this list implicitly.
+1 -1
View File
@@ -230,7 +230,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
if (!$_template->source->handler->recompiled) {
return file_get_contents($this->filepath);
}
return ($this->content ?? false);
return isset($this->content) ? $this->content : false;
}
/**
+4 -2
View File
@@ -135,7 +135,9 @@ class Smarty_Template_Source
*/
public function __construct(Smarty $smarty, $resource, $type, $name)
{
$this->handler = $smarty->_cache[ 'resource_handlers' ][ $type ] ?? Smarty_Resource::load($smarty, $type);
$this->handler =
isset($smarty->_cache[ 'resource_handlers' ][ $type ]) ? $smarty->_cache[ 'resource_handlers' ][ $type ] :
Smarty_Resource::load($smarty, $type);
$this->smarty = $smarty;
$this->resource = $resource;
$this->type = $type;
@@ -206,6 +208,6 @@ class Smarty_Template_Source
*/
public function getContent()
{
return ($this->content ?? $this->handler->getContent($this));
return isset($this->content) ? $this->content : $this->handler->getContent($this);
}
}
@@ -7,6 +7,33 @@
*/
class SmartyCompilerException extends SmartyException
{
/**
* The constructor of the exception
*
* @param string $message The Exception message to throw.
* @param int $code The Exception code.
* @param string|null $filename The filename where the exception is thrown.
* @param int|null $line The line number where the exception is thrown.
* @param Throwable|null $previous The previous exception used for the exception chaining.
*/
public function __construct(
string $message = "",
int $code = 0,
?string $filename = null,
?int $line = null,
Throwable $previous = null
) {
parent::__construct($message, $code, $previous);
// These are optional parameters, should be be overridden only when present!
if ($filename) {
$this->file = $filename;
}
if ($line) {
$this->line = $line;
}
}
/**
* @return string
*/