Skip to content

Commit

Permalink
Smarty no longer calls mb_internal_encoding() and doesn't check for…
Browse files Browse the repository at this point in the history
… deprecated `mbstring.func_overload` ini directive.

Fixes #480.
  • Loading branch information
wisskid committed Jan 31, 2023
1 parent 1ef29b6 commit 6635a5e
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- Smarty now always runs in multibyte mode, using `symfony/polyfill-mbstring` if required. Please use the
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
- `$smarty->getPluginsDir()`
Expand Down
12 changes: 0 additions & 12 deletions src/Compiler/Configfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,6 @@ public function compileTemplate(Template $template) {
);
/* @var ConfigfileParser $this->parser */
$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) {
$this->parser->PrintTrace();
}
Expand All @@ -127,9 +118,6 @@ public function compileTemplate(Template $template) {
}
// finish parsing process
$this->parser->doParse(0, 0);
if ($mbEncoding) {
mb_internal_encoding($mbEncoding);
}
if ($this->smarty->debugging) {
$this->smarty->getDebug()->end_compile($this->template);
}
Expand Down
12 changes: 0 additions & 12 deletions src/Compiler/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -1254,15 +1254,6 @@ protected function doCompile($_content, $isTemplateSource = false) {
if ($isTemplateSource && $this->template->caching) {
$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) {
$this->parser->PrintTrace();
$this->parser->lex->PrintTrace();
Expand All @@ -1277,9 +1268,6 @@ protected function doCompile($_content, $isTemplateSource = false) {
}
// finish parsing process
$this->parser->doParse(0, 0);
if ($mbEncoding) {
mb_internal_encoding($mbEncoding);
}
// check for unclosed tags
if ($this->getTagStackCount() > 0) {
// get stacked info
Expand Down
2 changes: 1 addition & 1 deletion src/Extension/DefaultExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public function smarty_modifier_escape($string, $esc_type = 'html', $char_set =
* @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 $encoding encoding of $string, if null mb_internal_encoding() is used
* @param string $encoding encoding of $string
*
* @return array sequence of unicodes
* @author Rodney Rehm
Expand Down
3 changes: 0 additions & 3 deletions src/Smarty.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,6 @@ class Smarty extends \Smarty\TemplateBase
public function __construct()
{

if (is_callable('mb_internal_encoding')) {
mb_internal_encoding(\Smarty\Smarty::$_CHARSET);
}
$this->start_time = microtime(true);
// Check if we're running on Windows
\Smarty\Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
Expand Down

0 comments on commit 6635a5e

Please sign in to comment.