diff --git a/docs/programmers/advanced-features/advanced-features-outputfilters.md b/docs/programmers/advanced-features/advanced-features-outputfilters.md
index 393d7da2..f40f4aa9 100644
--- a/docs/programmers/advanced-features/advanced-features-outputfilters.md
+++ b/docs/programmers/advanced-features/advanced-features-outputfilters.md
@@ -10,8 +10,7 @@ output filters operate on the template output when it is executed.
Output filters can be either [registered](#api.register.filter) or
loaded from the [plugins directory](#variable.plugins.dir) by using the
-[`loadFilter()`](#api.load.filter) method or by setting the
-[`$autoload_filters`](#variable.autoload.filters) variable. Smarty will
+[`loadFilter()`](#api.load.filter) method. Smarty will
pass the template output as the first argument, and expect the function
to return the result of the processing.
@@ -38,6 +37,5 @@ to return the result of the processing.
See also [`registerFilter()`](#api.register.filter),
[`loadFilter()`](#api.load.filter),
-[`$autoload_filters`](#variable.autoload.filters),
[postfilters](#advanced.features.postfilters) and
[`$plugins_dir`](#variable.plugins.dir).
diff --git a/docs/programmers/advanced-features/advanced-features-postfilters.md b/docs/programmers/advanced-features/advanced-features-postfilters.md
index d3bad546..890d8f0f 100644
--- a/docs/programmers/advanced-features/advanced-features-postfilters.md
+++ b/docs/programmers/advanced-features/advanced-features-postfilters.md
@@ -5,8 +5,7 @@ Template postfilters are PHP functions that your templates are ran
through *after they are compiled*. Postfilters can be either
[registered](#api.register.filter) or loaded from the [plugins
directory](#variable.plugins.dir) by using the
-[`loadFilter()`](#api.load.filter) function or by setting the
-[`$autoload_filters`](#variable.autoload.filters) variable. Smarty will
+[`loadFilter()`](#api.load.filter) function. Smarty will
pass the compiled template code as the first argument, and expect the
function to return the result of the processing.
diff --git a/docs/programmers/advanced-features/advanced-features-prefilters.md b/docs/programmers/advanced-features/advanced-features-prefilters.md
index 76229e63..bc84bea3 100644
--- a/docs/programmers/advanced-features/advanced-features-prefilters.md
+++ b/docs/programmers/advanced-features/advanced-features-prefilters.md
@@ -8,8 +8,7 @@ putting in their templates, etc.
Prefilters can be either [registered](#api.register.filter) or loaded
from the [plugins directory](#variable.plugins.dir) by using
-[`loadFilter()`](#api.load.filter) function or by setting the
-[`$autoload_filters`](#variable.autoload.filters) variable.
+[`loadFilter()`](#api.load.filter) function.
Smarty will pass the template source code as the first argument, and
expect the function to return the resulting template source code.
diff --git a/docs/programmers/api-functions/api-load-filter.md b/docs/programmers/api-functions/api-load-filter.md
index 19286ee3..7e46b131 100644
--- a/docs/programmers/api-functions/api-load-filter.md
+++ b/docs/programmers/api-functions/api-load-filter.md
@@ -37,6 +37,5 @@ specifies the `name` of the filter plugin.
-See also [`registerFilter()`](#api.register.filter),
-[`$autoload_filters`](#variable.autoload.filters) and [advanced
+See also [`registerFilter()`](#api.register.filter) and [advanced
features](#advanced.features).
diff --git a/docs/programmers/api-functions/api-register-filter.md b/docs/programmers/api-functions/api-register-filter.md
index fd91d266..4a2aa4b0 100644
--- a/docs/programmers/api-functions/api-register-filter.md
+++ b/docs/programmers/api-functions/api-register-filter.md
@@ -38,8 +38,7 @@ filters](#advanced.features.outputfilters) for more information on how
to set up an output filter function.
See also [`unregisterFilter()`](#api.unregister.filter),
-[`loadFilter()`](#api.load.filter),
-[`$autoload_filters`](#variable.autoload.filters), [template pre
+[`loadFilter()`](#api.load.filter), [template pre
filters](#advanced.features.prefilters) [template post
filters](#advanced.features.postfilters) [template output
filters](#advanced.features.outputfilters) section.
diff --git a/docs/programmers/api-variables.md b/docs/programmers/api-variables.md
index 902116c3..be3f86a1 100644
--- a/docs/programmers/api-variables.md
+++ b/docs/programmers/api-variables.md
@@ -6,7 +6,6 @@ them directly, or use the corresponding setter/getter methods.
- [$allow_php_templates](./api-variables/variable-allow-php-templates.md)
- [$auto_literal](./api-variables/variable-auto-literal.md)
-- [$autoload_filters](./api-variables/variable-autoload-filters.md)
- [$cache_dir](./api-variables/variable-cache-dir.md)
- [$cache_id](./api-variables/variable-cache-id.md)
- [$cache_lifetime](./api-variables/variable-cache-lifetime.md)
diff --git a/docs/programmers/api-variables/variable-autoload-filters.md b/docs/programmers/api-variables/variable-autoload-filters.md
deleted file mode 100644
index 8a300b06..00000000
--- a/docs/programmers/api-variables/variable-autoload-filters.md
+++ /dev/null
@@ -1,21 +0,0 @@
-\$autoload\_filters {#variable.autoload.filters}
-===================
-
-If there are some filters that you wish to load on every template
-invocation, you can specify them using this variable and Smarty will
-automatically load them for you. The variable is an associative array
-where keys are filter types and values are arrays of the filter names.
-For example:
-
-::: {.informalexample}
-
- autoload_filters = array('pre' => array('trim', 'stamp'),
- 'output' => array('convert'));
- ?>
-
-
-:::
-
-See also [`registerFilter()`](#api.register.filter) and
-[`loadFilter()`](#api.load.filter)
diff --git a/src/Compile/smarty_internal_compile_private_foreachsection.php b/src/Compile/smarty_internal_compile_private_foreachsection.php
index 246350dc..64d3e927 100644
--- a/src/Compile/smarty_internal_compile_private_foreachsection.php
+++ b/src/Compile/smarty_internal_compile_private_foreachsection.php
@@ -177,9 +177,7 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
$_content = $nextCompiler->template->source->getContent();
if ($_content !== '') {
// run pre filter if required
- if ((isset($nextCompiler->smarty->autoload_filters[ 'pre' ]) ||
- isset($nextCompiler->smarty->registered_filters[ 'pre' ]))
- ) {
+ if (isset($nextCompiler->smarty->registered_filters[ 'pre' ])) {
$_content = $nextCompiler->smarty->ext->_filterHandler->runFilter(
'pre',
$_content,
diff --git a/src/Compile/smarty_internal_compile_private_print_expression.php b/src/Compile/smarty_internal_compile_private_print_expression.php
index 69b83b57..c49501d6 100644
--- a/src/Compile/smarty_internal_compile_private_print_expression.php
+++ b/src/Compile/smarty_internal_compile_private_print_expression.php
@@ -109,18 +109,6 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
}
}
}
- // auto loaded filters
- if (isset($compiler->smarty->autoload_filters[ \Smarty\Smarty::FILTER_VARIABLE ])) {
- foreach ((array)$compiler->template->smarty->autoload_filters[ \Smarty\Smarty::FILTER_VARIABLE ] as $name) {
- $result = $this->compile_variable_filter($compiler, $name, $output);
- if ($result !== false) {
- $output = $result;
- } else {
- // not found, throw exception
- throw new SmartyException("Unable to load variable filter '{$name}'");
- }
- }
- }
foreach ($compiler->variable_filters as $filter) {
if (count($filter) === 1
&& ($result = $this->compile_variable_filter($compiler, $filter[ 0 ], $output)) !== false
diff --git a/src/Compiler/smarty_internal_templatecompilerbase.php b/src/Compiler/smarty_internal_templatecompilerbase.php
index 0484c1e1..2c41d59e 100644
--- a/src/Compiler/smarty_internal_templatecompilerbase.php
+++ b/src/Compiler/smarty_internal_templatecompilerbase.php
@@ -472,9 +472,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
public function postFilter($code)
{
// run post filter if on code
- if (!empty($code)
- && (isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ]))
- ) {
+ if (!empty($code) && isset($this->smarty->registered_filters[ 'post' ])) {
return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template);
} else {
return $code;
@@ -492,9 +490,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
public function preFilter($_content)
{
// run pre filter if required
- if ($_content !== ''
- && ((isset($this->smarty->autoload_filters[ 'pre' ]) || isset($this->smarty->registered_filters[ 'pre' ])))
- ) {
+ if ($_content !== '' && isset($this->smarty->registered_filters[ 'pre' ])) {
return $this->smarty->ext->_filterHandler->runFilter('pre', $_content, $this->template);
} else {
return $_content;
diff --git a/src/Debug.php b/src/Debug.php
index 07da997a..b1cb9f09 100644
--- a/src/Debug.php
+++ b/src/Debug.php
@@ -216,7 +216,6 @@ class Debug extends Data
$debObj->registered_plugins = array();
$debObj->registered_resources = array();
$debObj->registered_filters = array();
- $debObj->autoload_filters = array();
$debObj->default_modifiers = array();
$debObj->escape_html = true;
$debObj->caching = \Smarty::CACHING_OFF;
diff --git a/src/Method/smarty_internal_method_addautoloadfilters.php b/src/Method/smarty_internal_method_addautoloadfilters.php
deleted file mode 100644
index a05f55a8..00000000
--- a/src/Method/smarty_internal_method_addautoloadfilters.php
+++ /dev/null
@@ -1,53 +0,0 @@
-_getSmartyObj();
- if ($type !== null) {
- $this->_checkFilterType($type);
- if (!empty($smarty->autoload_filters[ $type ])) {
- $smarty->autoload_filters[ $type ] = array_merge($smarty->autoload_filters[ $type ], (array)$filters);
- } else {
- $smarty->autoload_filters[ $type ] = (array)$filters;
- }
- } else {
- foreach ((array)$filters as $type => $value) {
- $this->_checkFilterType($type);
- if (!empty($smarty->autoload_filters[ $type ])) {
- $smarty->autoload_filters[ $type ] =
- array_merge($smarty->autoload_filters[ $type ], (array)$value);
- } else {
- $smarty->autoload_filters[ $type ] = (array)$value;
- }
- }
- }
- return $obj;
- }
-}
diff --git a/src/Method/smarty_internal_method_getautoloadfilters.php b/src/Method/smarty_internal_method_getautoloadfilters.php
deleted file mode 100644
index 4145db10..00000000
--- a/src/Method/smarty_internal_method_getautoloadfilters.php
+++ /dev/null
@@ -1,37 +0,0 @@
- array( 'filter1', 'filter2', … ) ) or array( 'filter1', 'filter2', …) if $type
- * was specified
- * @throws \SmartyException
- */
- public function getAutoloadFilters(Smarty_Internal_TemplateBase $obj, $type = null)
- {
- $smarty = $obj->_getSmartyObj();
- if ($type !== null) {
- $this->_checkFilterType($type);
- return isset($smarty->autoload_filters[ $type ]) ? $smarty->autoload_filters[ $type ] : array();
- }
- return $smarty->autoload_filters;
- }
-}
diff --git a/src/Method/smarty_internal_method_setautoloadfilters.php b/src/Method/smarty_internal_method_setautoloadfilters.php
deleted file mode 100644
index 2972f3ce..00000000
--- a/src/Method/smarty_internal_method_setautoloadfilters.php
+++ /dev/null
@@ -1,72 +0,0 @@
- true, 'post' => true, 'output' => true, 'variable' => true);
-
- /**
- * Set autoload filters
- *
- * @api Smarty::setAutoloadFilters()
- *
- * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
- * @param array $filters filters to load automatically
- * @param string $type "pre", "output", … specify
- * the filter type to set.
- * Defaults to none treating
- * $filters' keys as the
- * appropriate types
- *
- * @return \Smarty|\Smarty_Internal_Template
- * @throws \SmartyException
- */
- public function setAutoloadFilters(Smarty_Internal_TemplateBase $obj, $filters, $type = null)
- {
- $smarty = $obj->_getSmartyObj();
- if ($type !== null) {
- $this->_checkFilterType($type);
- $smarty->autoload_filters[ $type ] = (array)$filters;
- } else {
- foreach ((array)$filters as $type => $value) {
- $this->_checkFilterType($type);
- }
- $smarty->autoload_filters = (array)$filters;
- }
- return $obj;
- }
-
- /**
- * Check if filter type is valid
- *
- * @param string $type
- *
- * @throws \SmartyException
- */
- public function _checkFilterType($type)
- {
- if (!isset($this->filterTypes[ $type ])) {
- throw new SmartyException("Illegal filter type '{$type}'");
- }
- }
-}
diff --git a/src/Runtime/smarty_internal_runtime_filterhandler.php b/src/Runtime/smarty_internal_runtime_filterhandler.php
index b54dd932..859fe848 100644
--- a/src/Runtime/smarty_internal_runtime_filterhandler.php
+++ b/src/Runtime/smarty_internal_runtime_filterhandler.php
@@ -32,28 +32,6 @@ class Smarty_Internal_Runtime_FilterHandler
*/
public function runFilter($type, $content, Smarty_Internal_Template $template)
{
- // loop over autoload filters of specified type
- if (!empty($template->smarty->autoload_filters[ $type ])) {
- foreach ((array)$template->smarty->autoload_filters[ $type ] as $name) {
- $plugin_name = "Smarty_{$type}filter_{$name}";
- if (function_exists($plugin_name)) {
- $callback = $plugin_name;
- } elseif (class_exists($plugin_name, false) && is_callable(array($plugin_name, 'execute'))) {
- $callback = array($plugin_name, 'execute');
- } else {
- if (function_exists($plugin_name)) {
- // use loaded Smarty2 style plugin
- $callback = $plugin_name;
- } elseif (class_exists($plugin_name, false) && is_callable(array($plugin_name, 'execute'))) {
- // loaded class of filter plugin
- $callback = array($plugin_name, 'execute');
- } else {
- throw new SmartyException("Auto load {$type}-filter plugin method '{$plugin_name}::execute' not callable");
- }
- }
- $content = call_user_func($callback, $content, $template);
- }
- }
// loop over registered filters of specified type
if (!empty($template->smarty->registered_filters[ $type ])) {
foreach ($template->smarty->registered_filters[ $type ] as $key => $name) {
diff --git a/src/Runtime/smarty_internal_runtime_updatecache.php b/src/Runtime/smarty_internal_runtime_updatecache.php
index 7359cc3a..c4511345 100644
--- a/src/Runtime/smarty_internal_runtime_updatecache.php
+++ b/src/Runtime/smarty_internal_runtime_updatecache.php
@@ -116,9 +116,10 @@ class Smarty_Internal_Runtime_UpdateCache
$content .= $cache_parts[ 2 ][ $curr_idx ];
}
}
- if (!$no_output_filter && !$_template->cached->has_nocache_code
- && (isset($_template->smarty->autoload_filters[ 'output' ])
- || isset($_template->smarty->registered_filters[ 'output' ]))
+ if (
+ !$no_output_filter
+ && !$_template->cached->has_nocache_code
+ && isset($_template->smarty->registered_filters[ 'output' ])
) {
$content = $_template->smarty->ext->_filterHandler->runFilter('output', $content, $_template);
}
diff --git a/src/Smarty.php b/src/Smarty.php
index e61b823f..98bb43a7 100644
--- a/src/Smarty.php
+++ b/src/Smarty.php
@@ -465,13 +465,6 @@ class Smarty extends \Smarty_Internal_TemplateBase
*/
public $registered_cache_resources = array();
- /**
- * autoload filter
- *
- * @var array
- */
- public $autoload_filters = array();
-
/**
* default modifier
*
diff --git a/src/smarty_internal_extension_handler.php b/src/smarty_internal_extension_handler.php
index b266d3d8..9ffa35f9 100644
--- a/src/smarty_internal_extension_handler.php
+++ b/src/smarty_internal_extension_handler.php
@@ -46,7 +46,7 @@ class Smarty_Internal_Extension_Handler
* @var array
*/
private $_property_info = array(
- 'AutoloadFilters' => 0, 'DefaultModifiers' => 0, 'ConfigVars' => 0,
+ 'DefaultModifiers' => 0, 'ConfigVars' => 0,
'DebugTemplate' => 0, 'RegisteredObject' => 0, 'StreamVariable' => 0,
'TemplateVars' => 0, 'Literals' => 'Literals',
);//
diff --git a/src/smarty_internal_template.php b/src/smarty_internal_template.php
index 8a073a6d..894d55c8 100644
--- a/src/smarty_internal_template.php
+++ b/src/smarty_internal_template.php
@@ -226,8 +226,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
);
} else {
if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled)
- && !$no_output_filter && (isset($this->smarty->autoload_filters[ 'output' ])
- || isset($this->smarty->registered_filters[ 'output' ]))
+ && !$no_output_filter && isset($this->smarty->registered_filters[ 'output' ])
) {
echo $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
} else {
@@ -247,10 +246,10 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
$this->smarty->_debug->display_debug($this, true);
}
}
- if (!$no_output_filter
+ if (
+ !$no_output_filter
&& (!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled)
- && (isset($this->smarty->autoload_filters[ 'output' ])
- || isset($this->smarty->registered_filters[ 'output' ]))
+ && isset($this->smarty->registered_filters[ 'output' ])
) {
return $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
}
diff --git a/src/smarty_internal_templatebase.php b/src/smarty_internal_templatebase.php
index ca5332cb..430f4185 100644
--- a/src/smarty_internal_templatebase.php
+++ b/src/smarty_internal_templatebase.php
@@ -19,11 +19,9 @@
* The following methods will be dynamically loaded by the extension handler when they are called.
* They are located in a corresponding Smarty_Internal_Method_xxxx class
*
- * @method Smarty_Internal_TemplateBase addAutoloadFilters(mixed $filters, string $type = null)
* @method Smarty_Internal_TemplateBase addDefaultModifiers(mixed $modifiers)
* @method Smarty_Internal_TemplateBase addLiterals(mixed $literals)
* @method Smarty_Internal_TemplateBase createData(\Smarty\Data $parent = null, string $name = null)
- * @method array getAutoloadFilters(string $type = null)
* @method string getDebugTemplate()
* @method array getDefaultModifier()
* @method array getLiterals()
@@ -34,7 +32,6 @@
* @method Smarty_Internal_TemplateBase registerDefaultPluginHandler(callback $callback)
* @method Smarty_Internal_TemplateBase registerDefaultTemplateHandler(callback $callback)
* @method Smarty_Internal_TemplateBase registerResource(string $name, mixed $resource_handler)
- * @method Smarty_Internal_TemplateBase setAutoloadFilters(mixed $filters, string $type = null)
* @method Smarty_Internal_TemplateBase setDebugTemplate(string $tpl_name)
* @method Smarty_Internal_TemplateBase setDefaultModifiers(mixed $modifiers)
* @method Smarty_Internal_TemplateBase setLiterals(mixed $literals)
diff --git a/tests/UnitTests/A_Core/Filter/FilterTest.php b/tests/UnitTests/A_Core/Filter/FilterTest.php
index 0fd26254..0ab64251 100644
--- a/tests/UnitTests/A_Core/Filter/FilterTest.php
+++ b/tests/UnitTests/A_Core/Filter/FilterTest.php
@@ -26,26 +26,6 @@ class FilterTest extends PHPUnit_Smarty
$this->cleanDirs();
}
- /**
- * test autoload output filter
- */
- public function testAutoloadOutputFilter()
- {
- $this->smarty->autoload_filters[ 'output' ] = 'trimwhitespace';
- $tpl = $this->smarty->createTemplate('eval:{"
hello world"}');
- $this->assertEquals("
hello world", $this->smarty->fetch($tpl));
- }
-
- /**
- * test autoload variable filter
- */
- public function testAutoloadVariableFilter()
- {
- $this->smarty->autoload_filters[ 'variable' ] = 'htmlspecialchars';
- $tpl = $this->smarty->createTemplate('eval:{""}');
- $this->assertEquals("<test>", $this->smarty->fetch($tpl));
- }
-
/**
* test loaded filter
*/