Skip to content

Commit 1393b83

Browse files
authored
Merge pull request #5727 from magento-tsg/2.4.0-develop-pr45
[TSG] Fixes for 2.4 (pr45) (2.4.0-develop)
2 parents 10b0c94 + 5be291d commit 1393b83

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

dev/tests/integration/testsuite/Magento/Framework/Filter/VariableResolver/LegacyResolverTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public function getThing()
117117
['foo' => $dataClassStub, 'g' => ['h' => ['i' => 'abc']]],
118118
'abca=123,b=321,'
119119
],
120+
'disallow __callParent method' => ['foo.___callParent()',['foo' => $classStub], null],
120121
];
121122
}
122123
}

lib/internal/Magento/Framework/Filter/VariableResolver/LegacyResolver.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,31 @@ private function handleObjectMethod(Template $filter, array $templateVariables,
160160
{
161161
$object = $stackArgs[$i - 1]['variable'];
162162
$method = $stackArgs[$i]['name'];
163-
if (method_exists($object, $method) && substr($method, 0, 3) !== 'set') {
163+
if ($this->isMethodCallable($object, $method)) {
164164
$args = $this->getStackArgs($stackArgs[$i]['args'], $filter, $templateVariables);
165165
$stackArgs[$i]['variable'] = call_user_func_array([$object, $method], $args);
166166
}
167167
}
168168

169+
/**
170+
* Check if object method can be called.
171+
*
172+
* @param mixed $object
173+
* @param string $method
174+
* @return bool
175+
*/
176+
private function isMethodCallable($object, string $method): bool
177+
{
178+
if (method_exists($object, $method)
179+
&& substr($method, 0, 3) !== 'set'
180+
&& $method !== '___callParent'
181+
) {
182+
return true;
183+
}
184+
185+
return false;
186+
}
187+
169188
/**
170189
* Return if the given index should be processed for data access
171190
*

0 commit comments

Comments
 (0)