Merge pull request #9435 from unclecheese/pulls/4.5/wha-diff

BUGFIX: Ensure diff arrays are one-dimensional
This commit is contained in:
Loz Calver 2020-04-01 09:16:20 +01:00 committed by GitHub
commit 39fab1974a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -174,6 +174,7 @@ class Diff extends \Diff
$content = $content ? "true" : "false";
}
if (is_array($content)) {
$content = array_filter($content, 'is_scalar');
// Convert array to CSV
$content = implode(',', $content);
}

View File

@ -77,4 +77,14 @@ class DiffTest extends SapphireTest
$this->assertRegExp($expected, $actual);
}
public function testDiffArray()
{
$from = ['Lorem', ['array here please ignore'], 'ipsum dolor'];
$to = 'Lorem,ipsum';
$expected = "/^Lorem,ipsum *<del>dolor<\/del> *$/";
$actual = Diff::compareHTML($from, $to);
$this->assertRegExp($expected, $actual);
}
}