summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Wisselink <wisskid@users.noreply.github.com>2024-11-20 23:05:14 +0100
committerGitHub <noreply@github.com>2024-11-20 23:05:14 +0100
commitf47ac761af7a64922da7992711e83d612e25000c (patch)
tree4b272cac11f195d34c4db2db16c28b905369e454
parent642a97adcc2bf6c1b2458d6afeeb36ae001c1c2f (diff)
downloadsmarty-f47ac761af7a64922da7992711e83d612e25000c.tar.gz
smarty-f47ac761af7a64922da7992711e83d612e25000c.tar.bz2
smarty-f47ac761af7a64922da7992711e83d612e25000c.zip
replace/qualify call_user_func_array. (#1083)
Fixes #1074
-rw-r--r--changelog/1074.md1
-rw-r--r--src/BlockHandler/BlockPluginWrapper.php2
-rw-r--r--src/Compiler/Template.php9
-rw-r--r--src/Extension/CallbackWrapper.php2
-rw-r--r--src/Runtime/DefaultPluginHandlerRuntime.php4
-rw-r--r--src/Template/Source.php2
6 files changed, 11 insertions, 9 deletions
diff --git a/changelog/1074.md b/changelog/1074.md
new file mode 100644
index 00000000..845c4b5b
--- /dev/null
+++ b/changelog/1074.md
@@ -0,0 +1 @@
+- Fix PHP backtraces by qualifying/replacing `call_user_func_array` calls [#1074](https://github.com/smarty-php/smarty/issues/1074) \ No newline at end of file
diff --git a/src/BlockHandler/BlockPluginWrapper.php b/src/BlockHandler/BlockPluginWrapper.php
index 47005945..b6236a67 100644
--- a/src/BlockHandler/BlockPluginWrapper.php
+++ b/src/BlockHandler/BlockPluginWrapper.php
@@ -14,6 +14,6 @@ class BlockPluginWrapper extends Base {
}
public function handle($params, $content, Template $template, &$repeat) {
- return call_user_func_array($this->callback, [$params, $content, &$template, &$repeat]);
+ return \call_user_func_array($this->callback, [$params, $content, &$template, &$repeat]);
}
} \ No newline at end of file
diff --git a/src/Compiler/Template.php b/src/Compiler/Template.php
index de802e1c..4f798bfd 100644
--- a/src/Compiler/Template.php
+++ b/src/Compiler/Template.php
@@ -665,7 +665,7 @@ class Template extends BaseCompiler {
$script = null;
$cacheable = true;
- $result = call_user_func_array(
+ $result = \call_user_func_array(
$defaultPluginHandlerFunc,
[
$tag,
@@ -1281,9 +1281,10 @@ class Template extends BaseCompiler {
}
// call post compile callbacks
foreach ($this->postCompileCallbacks as $cb) {
- $parameter = $cb;
- $parameter[0] = $this;
- call_user_func_array($cb[0], $parameter);
+ $callbackFunction = $cb[0];
+ $parameters = $cb;
+ $parameters[0] = $this;
+ $callbackFunction(...$parameters);
}
// return compiled code
return $this->prefixCompiledCode . $this->parser->retvalue . $this->postfixCompiledCode;
diff --git a/src/Extension/CallbackWrapper.php b/src/Extension/CallbackWrapper.php
index 827dd78b..193fc136 100644
--- a/src/Extension/CallbackWrapper.php
+++ b/src/Extension/CallbackWrapper.php
@@ -26,7 +26,7 @@ class CallbackWrapper {
public function handle(...$params) {
try {
- return call_user_func_array($this->callback, $params);
+ return ($this->callback)(...$params);
} catch (\ArgumentCountError $e) {
throw new Exception("Invalid number of arguments to modifier " . $this->modifierName);
}
diff --git a/src/Runtime/DefaultPluginHandlerRuntime.php b/src/Runtime/DefaultPluginHandlerRuntime.php
index ad6ed74d..f3be85ca 100644
--- a/src/Runtime/DefaultPluginHandlerRuntime.php
+++ b/src/Runtime/DefaultPluginHandlerRuntime.php
@@ -26,7 +26,7 @@ class DefaultPluginHandlerRuntime {
$script = null;
$cacheable = null;
- return (call_user_func_array(
+ return (\call_user_func_array(
$this->defaultPluginHandler,
[
$tag,
@@ -54,7 +54,7 @@ class DefaultPluginHandlerRuntime {
$script = null;
$cacheable = null;
- if (call_user_func_array(
+ if (\call_user_func_array(
$this->defaultPluginHandler,
[
$tag,
diff --git a/src/Template/Source.php b/src/Template/Source.php
index 2ef13a48..2c2022ee 100644
--- a/src/Template/Source.php
+++ b/src/Template/Source.php
@@ -203,7 +203,7 @@ class Source {
*/
public function _getDefaultTemplate($default_handler) {
$_content = $_timestamp = null;
- $_return = call_user_func_array(
+ $_return = \call_user_func_array(
$default_handler,
[$this->type, $this->name, &$_content, &$_timestamp, $this->smarty]
);