Skip to content

Commit c18fc16

Browse files
Merge MC-11058 into 2.3-bugfixes-070219
2 parents c11ba38 + b2a3c41 commit c18fc16

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/internal/Magento/Framework/Filter/Template.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,10 @@ protected function getVariable($value, $default = '{no_value_defined}')
436436
}
437437
}
438438
$last = $i;
439-
} elseif (isset($stackVars[$i - 1]['variable']) && $stackVars[$i]['type'] == 'method') {
439+
} elseif (isset($stackVars[$i - 1]['variable'])
440+
&& is_object($stackVars[$i - 1]['variable'])
441+
&& $stackVars[$i]['type'] == 'method'
442+
) {
440443
// Calling object methods
441444
$object = $stackVars[$i - 1]['variable'];
442445
$method = $stackVars[$i]['name'];

lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,18 @@ private function getObjectData()
381381
return $dataObject;
382382
}
383383

384+
/**
385+
* Check that if calling a method of an object fails expected result is returned.
386+
*/
387+
public function testInvalidMethodCall()
388+
{
389+
$this->templateFilter->setVariables(['dateTime' => '\DateTime']);
390+
$this->assertEquals(
391+
'\DateTime',
392+
$this->templateFilter->filter('{{var dateTime.createFromFormat(\'d\',\'1548201468\')}}')
393+
);
394+
}
395+
384396
/**
385397
* Test adding callbacks when already filtering.
386398
*

0 commit comments

Comments
 (0)