Skip to content

Commit

Permalink
Merge pull request #10912 from kinglozzer/10911-template-regression
Browse files Browse the repository at this point in the history
FIX: Regression with include argument (fixes #10911)
  • Loading branch information
GuySartorelli authored Aug 9, 2023
2 parents 0e74e35 + 8da4aa8 commit 4ccfc37
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/View/SSViewer_DataPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ protected function getValueSource($property)
// 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 [];
}

Expand Down
27 changes: 21 additions & 6 deletions tests/php/View/SSViewerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1035,38 +1035,53 @@ public function testIncludeWithArguments()
{
$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(
$this->render(
'<% 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(
$this->render(
'<% 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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>$Arg1</p><p>$Arg2</p>
<p>$Arg1</p><p>$Arg2</p><p>{$Arg2.Count}</p>

0 comments on commit 4ccfc37

Please sign in to comment.