diff --git a/code/CMSMain.php b/code/CMSMain.php index fe99fd9c..51dac639 100644 --- a/code/CMSMain.php +++ b/code/CMSMain.php @@ -847,12 +847,16 @@ JS; $record = $page->compareVersions($fromVersion, $toVersion); $fromVersionRecord = Versioned::get_version('SiteTree', $id, $fromVersion); $toVersionRecord = Versioned::get_version('SiteTree', $id, $toVersion); + if(!$fromVersionRecord) user_error("Can't find version $fromVersion of page $id", E_USER_ERROR); + if(!$toVersionRecord) user_error("Can't find version $toVersion of page $id", E_USER_ERROR); if($record) { $fromDateNice = $fromVersionRecord->obj('LastEdited')->Ago(); $toDateNice = $toVersionRecord->obj('LastEdited')->Ago(); $fromAuthor = DataObject::get_by_id('Member', $fromVersionRecord->AuthorID); + if(!$fromAuthor) $fromAuthor = new ArrayData(array('Title' => 'Unknown author')); $toAuthor = DataObject::get_by_id('Member', $toVersionRecord->AuthorID); + if(!$toAuthor) $toAuthor = new ArrayData(array('Title' => 'Unknown author')); $fields = $record->getCMSFields($this); $fields->push(new HiddenField("ID")); diff --git a/code/Diff.php b/code/Diff.php index 935ad810..ef2825e6 100755 --- a/code/Diff.php +++ b/code/Diff.php @@ -664,9 +664,12 @@ class Diff // First split up the content into words and tags $set1 = self::getHTMLChunks($from); $set2 = self::getHTMLChunks($to); - + // Diff that $diff = new Diff($set1, $set2); + + $tagStack[1] = $tagStack[2] = 0; + $rechunked[1] = $rechunked[2] = array(); // Go through everything, converting edited tags (and their content) into single chunks. Otherwise // the generated HTML gets crusty @@ -704,12 +707,12 @@ class Diff if($chunks) { foreach($chunks as $item) { // $tagStack > 0 indicates that we should be tag-building - if(isset($tagStack[$listName])) $rechunked[$listName][sizeof($rechunked[$listName])-1] .= ' ' . $item; + if($tagStack[$listName]) $rechunked[$listName][sizeof($rechunked[$listName])-1] .= ' ' . $item; else $rechunked[$listName][] = $item; if($lookForTag && isset($item[0]) && $item[0] == "<" && substr($item,0,2) != "