Smarty no longer calls mb_internal_encoding() and doesn't check for deprecated mbstring.func_overload ini directive.

Fixes #480.
This commit is contained in:
Simon Wisselink
2023-01-31 10:53:10 +01:00
parent 1ef29b65ea
commit 6635a5e3fb
5 changed files with 2 additions and 28 deletions

View File

@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Lexers and Parsers PHP files are no longer under version control, but generated from sources (.y and .plex) - Lexers and Parsers PHP files are no longer under version control, but generated from sources (.y and .plex)
- Smarty now always runs in multibyte mode, using `symfony/polyfill-mbstring` if required. Please use the - Smarty now always runs in multibyte mode, using `symfony/polyfill-mbstring` if required. Please use the
multibyte extension for optimal performance. multibyte extension for optimal performance.
- Smarty no longer calls `mb_internal_encoding()` and doesn't check for deprecated `mbstring.func_overload` ini directive [#480](https://github.com/smarty-php/smarty/issues/480)
### Deprecated ### Deprecated
- `$smarty->getPluginsDir()` - `$smarty->getPluginsDir()`

View File

@@ -106,15 +106,6 @@ class Configfile extends BaseCompiler {
); );
/* @var ConfigfileParser $this->parser */ /* @var ConfigfileParser $this->parser */
$this->parser = new ConfigfileParser($this->lex, $this); $this->parser = new ConfigfileParser($this->lex, $this);
if (function_exists('mb_internal_encoding')
&& function_exists('ini_get')
&& ((int)ini_get('mbstring.func_overload')) & 2
) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
} else {
$mbEncoding = null;
}
if ($this->smarty->_parserdebug) { if ($this->smarty->_parserdebug) {
$this->parser->PrintTrace(); $this->parser->PrintTrace();
} }
@@ -127,9 +118,6 @@ class Configfile extends BaseCompiler {
} }
// finish parsing process // finish parsing process
$this->parser->doParse(0, 0); $this->parser->doParse(0, 0);
if ($mbEncoding) {
mb_internal_encoding($mbEncoding);
}
if ($this->smarty->debugging) { if ($this->smarty->debugging) {
$this->smarty->getDebug()->end_compile($this->template); $this->smarty->getDebug()->end_compile($this->template);
} }

View File

@@ -1254,15 +1254,6 @@ class Template extends BaseCompiler {
if ($isTemplateSource && $this->template->caching) { if ($isTemplateSource && $this->template->caching) {
$this->parser->insertPhpCode("<?php\n\$_smarty_tpl->getCompiled()->nocache_hash = '{$this->nocache_hash}';\n?>\n"); $this->parser->insertPhpCode("<?php\n\$_smarty_tpl->getCompiled()->nocache_hash = '{$this->nocache_hash}';\n?>\n");
} }
if (function_exists('mb_internal_encoding')
&& function_exists('ini_get')
&& ((int)ini_get('mbstring.func_overload')) & 2
) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('ASCII');
} else {
$mbEncoding = null;
}
if ($this->smarty->_parserdebug) { if ($this->smarty->_parserdebug) {
$this->parser->PrintTrace(); $this->parser->PrintTrace();
$this->parser->lex->PrintTrace(); $this->parser->lex->PrintTrace();
@@ -1277,9 +1268,6 @@ class Template extends BaseCompiler {
} }
// finish parsing process // finish parsing process
$this->parser->doParse(0, 0); $this->parser->doParse(0, 0);
if ($mbEncoding) {
mb_internal_encoding($mbEncoding);
}
// check for unclosed tags // check for unclosed tags
if ($this->getTagStackCount() > 0) { if ($this->getTagStackCount() > 0) {
// get stacked info // get stacked info

View File

@@ -488,7 +488,7 @@ class DefaultExtension extends Base {
* @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration * @link http://www.ibm.com/developerworks/library/os-php-unicode/index.html#listing3 for inspiration
* *
* @param string $string characters to calculate unicode of * @param string $string characters to calculate unicode of
* @param string $encoding encoding of $string, if null mb_internal_encoding() is used * @param string $encoding encoding of $string
* *
* @return array sequence of unicodes * @return array sequence of unicodes
* @author Rodney Rehm * @author Rodney Rehm

View File

@@ -531,9 +531,6 @@ class Smarty extends \Smarty\TemplateBase
public function __construct() public function __construct()
{ {
if (is_callable('mb_internal_encoding')) {
mb_internal_encoding(\Smarty\Smarty::$_CHARSET);
}
$this->start_time = microtime(true); $this->start_time = microtime(true);
// Check if we're running on Windows // Check if we're running on Windows
\Smarty\Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; \Smarty\Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';