$this->objectList->getConditionBuilder()->add('objectID = ?', [$this->objectID]);
$this->objectList->readObjects();
- $differ = Diff::getDefaultDiffer();
+ // set default values
+ if (!isset($_REQUEST['oldID']) && !isset($_REQUEST['newID'])) {
+ foreach ($this->objectList as $object) {
+ $this->oldID = $object->entryID;
+ $this->old = $object;
+ break;
+ }
+ $this->newID = 'current';
+ $this->new = $this->object;
+ }
// valid IDs were given, calculate diff
if ($this->old && $this->new) {
+ $differ = Diff::getDefaultDiffer();
+
$a = \explode("\n", $this->prepareMessage($this->old->getMessage()));
$b = \explode("\n", $this->prepareMessage($this->new->getMessage()));
$this->diff = Diff::rawDiffFromSebastianDiff($differ->diffToArray($a, $b));
}
}
}
-
- // set default values
- if (!isset($_REQUEST['oldID']) && !isset($_REQUEST['newID'])) {
- foreach ($this->objectList as $object) {
- $this->oldID = $object->entryID;
- break;
- }
- $this->newID = 'current';
- }
}
private function prepareMessage(string $message): string