Merge pull request #96 from dnadesign/fix/type-error-when-null

Make sureHtmlDiff::compareHTML is not passed null values
This commit is contained in:
Guy Sartorelli 2024-02-13 11:55:45 +13:00 committed by GitHub
commit 935e1dabc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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