Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if ini_get/ini_set is not disabled before using it #362

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion libs/sysplugins/smarty_internal_cacheresource_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ public function writeCachedContent(Smarty_Internal_Template $_template, $content
if ($_template->smarty->ext->_writeFile->writeFile($_template->cached->filepath, $content,
$_template->smarty) === true
) {
if (function_exists('opcache_invalidate') && strlen(ini_get("opcache.restrict_api")) < 1) {
if (function_exists('opcache_invalidate')
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)) {
opcache_invalidate($_template->cached->filepath, true);
} elseif (function_exists('apc_compile_file')) {
apc_compile_file($_template->cached->filepath);
Expand Down
4 changes: 3 additions & 1 deletion libs/sysplugins/smarty_internal_config_file_compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ public function compileTemplate(Smarty_Internal_Template $template)
/* @var Smarty_Internal_ConfigFileParser $this->parser */
$this->parser = new $this->parser_class($this->lex, $this);

if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public function clearCompiledTemplate(Smarty $smarty, $resource_name = null, $co

if ($unlink && @unlink($_filepath)) {
$_count ++;
if (function_exists('opcache_invalidate') && strlen(ini_get("opcache.restrict_api")) < 1) {
if (function_exists('opcache_invalidate')
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)) {
opcache_invalidate($_filepath, true);
}
}
Expand Down
10 changes: 7 additions & 3 deletions libs/sysplugins/smarty_internal_resource_php.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Smarty_Internal_Resource_Php extends Smarty_Internal_Resource_File
*/
public function __construct()
{
$this->short_open_tag = ini_get('short_open_tag');
$this->short_open_tag = function_exists('ini_get') ? ini_get('short_open_tag') : 1;
}

/**
Expand Down Expand Up @@ -79,13 +79,17 @@ public function renderUncompiled(Smarty_Template_Source $source, Smarty_Internal
extract($_template->getTemplateVars());

// include PHP template with short open tags enabled
ini_set('short_open_tag', '1');
if (function_exists('ini_set')) {
ini_set('short_open_tag', '1');
}
/** @var Smarty_Internal_Template $_smarty_template
* used in included file
*/
$_smarty_template = $_template;
include($source->filepath);
ini_set('short_open_tag', $this->short_open_tag);
if (function_exists('ini_set')) {
ini_set('short_open_tag', $this->short_open_tag);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $e
}
}
$_count += @unlink($_filepath) ? 1 : 0;
if (function_exists('opcache_invalidate') && strlen(ini_get("opcache.restrict_api")) < 1) {
if (function_exists('opcache_invalidate')
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)) {
opcache_invalidate($_filepath, true);
}
}
Expand Down
4 changes: 3 additions & 1 deletion libs/sysplugins/smarty_internal_smartytemplatecompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ protected function doCompile($_content, $isTemplateSource = false)
if ($isTemplateSource && $this->template->caching) {
$this->parser->insertPhpCode("<?php\n\$_smarty_tpl->compiled->nocache_hash = '{$this->nocache_hash}';\n?>\n");
}
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
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 {
Expand Down
3 changes: 2 additions & 1 deletion libs/sysplugins/smarty_template_compiled.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ public function process(Smarty_Internal_Template $_smarty_tpl)
*/
private function loadCompiledTemplate(Smarty_Internal_Template $_smarty_tpl)
{
if (function_exists('opcache_invalidate') && strlen(ini_get("opcache.restrict_api")) < 1) {
if (function_exists('opcache_invalidate')
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)) {
opcache_invalidate($this->filepath, true);
} elseif (function_exists('apc_compile_file')) {
apc_compile_file($this->filepath);
Expand Down