Merge pull request #10912 from kinglozzer/10911-template-regression

FIX: Regression with include argument (fixes #10911)
This commit is contained in:
Guy Sartorelli 2023-08-10 11:17:33 +12:00 committed by GitHub
commit 4ccfc371c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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>