FIX: Make sureHtmlDiff::compareHTML is not passed null values

This commit is contained in:
Alexandre Saelens 2024-01-23 13:22:47 +13:00
parent b9ee99d56b
commit c10085c99e

View File

@ -94,7 +94,7 @@ class VersionFeed extends SiteTreeExtension
if (isset($previous)) {
// Produce the diff fields for use in the template.
if ($version->Title != $previous->Title) {
$diffTitle = HtmlDiff::compareHTML($version->Title, $previous->Title);
$diffTitle = HtmlDiff::compareHTML($version->Title ?? '', $previous->Title ?? '');
$version->DiffTitle = DBField::create_field('HTMLText', null);
$version->DiffTitle->setValue(
@ -107,7 +107,7 @@ class VersionFeed extends SiteTreeExtension
}
if ($version->Content != $previous->Content) {
$diffContent = HtmlDiff::compareHTML($version->Content, $previous->Content);
$diffContent = HtmlDiff::compareHTML($version->Content ?? '', $previous->Content ?? '');
$version->DiffContent = DBField::create_field('HTMLText', null);
$version->DiffContent->setValue('<div>'.$diffContent.'</div>');