aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--inc/ChangeLog/ChangeLog.php12
-rw-r--r--inc/Ui/Diff.php30
2 files changed, 30 insertions, 12 deletions
diff --git a/inc/ChangeLog/ChangeLog.php b/inc/ChangeLog/ChangeLog.php
index 66a84484c..3f160a52f 100644
--- a/inc/ChangeLog/ChangeLog.php
+++ b/inc/ChangeLog/ChangeLog.php
@@ -663,4 +663,16 @@ abstract class ChangeLog
$this->cache[$this->id][$this->currentRevision] = $revInfo;
return $this->getRevisionInfo($this->currentRevision);
}
+
+ /**
+ * Mechanism to trace no-actual external current revision
+ * @param int $rev
+ */
+ public function traceCurrentRevision($rev)
+ {
+ if ($rev > $this->lastRevision()) {
+ $rev = $this->currentRevision();
+ }
+ return $rev;
+ }
}
diff --git a/inc/Ui/Diff.php b/inc/Ui/Diff.php
index d534016b8..3a6d8ef4e 100644
--- a/inc/Ui/Diff.php
+++ b/inc/Ui/Diff.php
@@ -95,27 +95,33 @@ abstract class Diff extends Ui
{
global $INPUT;
- // difflink icon click, eg. ?rev=123456789&do=diff
+ // difflink icon click, eg. &do=diff&rev=#
if ($INPUT->has('rev')) {
$this->oldRev = $INPUT->int('rev');
$this->newRev = $this->changelog->currentRevision();
}
- // submit button with two checked boxes
- $rev2 = $INPUT->arr('rev2', []);
- if (count($rev2) > 1) {
- if ($rev2[0] < $rev2[1]) {
- [$this->oldRev, $this->newRev] = [$rev2[0], $rev2[1]];
- } else {
- [$this->oldRev, $this->newRev] = [$rev2[1], $rev2[0]];
- }
+ // submit button with two checked boxes, eg. &do=diff&rev2[0]=#&rev2[1]=#
+ $revs = $INPUT->arr('rev2', []);
+ if (count($revs) > 1) {
+ list($rev1, $rev2) = $revs;
+ if ($rev2 < $rev1) [$rev1, $rev2] = [$rev2, $rev1];
+ $this->oldRev = (int)$rev1;
+ $this->newRev = (int)$this->changelog->traceCurrentRevision($rev2);
}
+
if (!isset($this->oldRev, $this->newRev)) {
// no revision was given, compare previous to current
- $revs = $this->changelog->getRevisions(-1, 2);
- $this->newRev = $this->changelog->currentRevision();
- $this->oldRev = ($revs[0] == $this->newRev) ? $revs[1] : $revs[0];
+ $rev2 = $this->changelog->currentRevision();
+ if ($rev2 > $this->changelog->lastRevision()) {
+ $rev1 = $this->changelog->lastRevision();
+ } else {
+ $revs = $changelog->getRevisions(0, 1);
+ $rev1 = count($revs) ? $revs[0] : false;
+ }
+ $this->oldRev = $rev1;
+ $this->newRev = $rev2;
}
}
}