Show the comparison with the previous version by default
authorMarcel Werk <burntime@woltlab.com>
Thu, 4 Apr 2024 15:49:35 +0000 (17:49 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 4 Apr 2024 15:49:35 +0000 (17:49 +0200)
wcfsetup/install/files/lib/page/EditHistoryPage.class.php

index 5b2a6c1190655719376f05df136e119558054af7..1fe186fcda1cdb2920932567c22cb9097f71fad4 100644 (file)
@@ -170,10 +170,21 @@ class EditHistoryPage extends AbstractPage
         $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));
@@ -211,15 +222,6 @@ class EditHistoryPage extends AbstractPage
                 }
             }
         }
-
-        // 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