Support only providing oldID in EditHistoryPage
authorTim Düsterhus <duesterhus@woltlab.com>
Sat, 19 Jul 2014 13:54:38 +0000 (15:54 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sat, 19 Jul 2014 13:54:38 +0000 (15:54 +0200)
It can be useful, if you only know the edit history entry that
corresponds to the old version of the item. The user can select
the appropriate “newID” to compare with.

wcfsetup/install/files/lib/page/EditHistoryPage.class.php

index 0536a2089b14f4a1fb22f4a77e25b30b1e3c0719..e3170cb4a7c811f0cc2d228fefd7098234b8a8ab 100644 (file)
@@ -79,12 +79,12 @@ class EditHistoryPage extends AbstractPage {
        public function readParameters() {
                parent::readParameters();
                
-               if (isset($_REQUEST['oldID']) && isset($_REQUEST['newID'])) {
+               if (isset($_REQUEST['oldID'])) {
                        $this->oldID = intval($_REQUEST['oldID']);
                        $this->old = new EditHistoryEntry($this->oldID);
                        if (!$this->old->entryID) throw new IllegalLinkException();
                        
-                       if ($_REQUEST['newID'] !== 'current') {
+                       if (isset($_REQUEST['newID']) && $_REQUEST['newID'] !== 'current') {
                                $this->newID = intval($_REQUEST['newID']);
                                $this->new = new EditHistoryEntry($this->newID);
                                if (!$this->new->entryID) throw new IllegalLinkException();
@@ -135,7 +135,7 @@ class EditHistoryPage extends AbstractPage {
                $this->objectList->readObjects();
                
                // valid IDs were given, calculate diff
-               if ($this->old) {
+               if ($this->old && $this->new) {
                        $a = explode("\n", StringUtil::unifyNewlines($this->old->getMessage()));
                        $b = explode("\n", StringUtil::unifyNewlines($this->new->getMessage()));
                        $this->diff = new Diff($a, $b);