FIX: Regression with include argument (fixes #10911)

This commit is contained in:
Loz Calver 2023-08-09 15:20:54 +01:00
parent 0e74e355eb
commit 8da4aa8637
3 changed files with 23 additions and 8 deletions

View File

@ -377,7 +377,7 @@ class SSViewer_DataPresenter extends SSViewer_Scope
// Check if the method to-be-called exists on the target object - if so, don't check any further
// injection locations
$on = $this->itemIterator ? $this->itemIterator->current() : $this->item;
if ($on !== null && (isset($on->$property) || method_exists($on, $property ?? ''))) {
if (is_object($on) && (isset($on->$property) || method_exists($on, $property ?? ''))) {
return [];
}

View File

@ -1035,22 +1035,22 @@ after'
{
$this->assertEquals(
$this->render('<% include SSViewerTestIncludeWithArguments %>'),
'<p>[out:Arg1]</p><p>[out:Arg2]</p>'
'<p>[out:Arg1]</p><p>[out:Arg2]</p><p>[out:Arg2.Count]</p>'
);
$this->assertEquals(
$this->render('<% include SSViewerTestIncludeWithArguments Arg1=A %>'),
'<p>A</p><p>[out:Arg2]</p>'
'<p>A</p><p>[out:Arg2]</p><p>[out:Arg2.Count]</p>'
);
$this->assertEquals(
$this->render('<% include SSViewerTestIncludeWithArguments Arg1=A, Arg2=B %>'),
'<p>A</p><p>B</p>'
'<p>A</p><p>B</p><p></p>'
);
$this->assertEquals(
$this->render('<% include SSViewerTestIncludeWithArguments Arg1=A Bare String, Arg2=B Bare String %>'),
'<p>A Bare String</p><p>B Bare String</p>'
'<p>A Bare String</p><p>B Bare String</p><p></p>'
);
$this->assertEquals(
@ -1058,7 +1058,7 @@ after'
'<% include SSViewerTestIncludeWithArguments Arg1="A", Arg2=$B %>',
new ArrayData(['B' => 'Bar'])
),
'<p>A</p><p>Bar</p>'
'<p>A</p><p>Bar</p><p></p>'
);
$this->assertEquals(
@ -1066,7 +1066,22 @@ after'
'<% include SSViewerTestIncludeWithArguments Arg1="A" %>',
new ArrayData(['Arg1' => 'Foo', 'Arg2' => 'Bar'])
),
'<p>A</p><p>Bar</p>'
'<p>A</p><p>Bar</p><p></p>'
);
$this->assertEquals(
$this->render('<% include SSViewerTestIncludeWithArguments Arg1="A", Arg2=0 %>'),
'<p>A</p><p>0</p><p></p>'
);
$this->assertEquals(
$this->render('<% include SSViewerTestIncludeWithArguments Arg1="A", Arg2=false %>'),
'<p>A</p><p></p><p></p>'
);
$this->assertEquals(
$this->render('<% include SSViewerTestIncludeWithArguments Arg1="A", Arg2=null %>'),
'<p>A</p><p></p><p></p>'
);
$this->assertEquals(

View File

@ -1 +1 @@
<p>$Arg1</p><p>$Arg2</p>
<p>$Arg1</p><p>$Arg2</p><p>{$Arg2.Count}</p>