Skip to content

Commit 25e910d

Browse files
committed
Never load serial data in page editor
fixes #535 Previously the page data editor pulled anything from the database associated with the current page id and having rev <= current timestamp. This included serial data with rev = 0, which are now excluded.
1 parent 96b3193 commit 25e910d

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

meta/AccessTablePage.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,25 @@ public function clearData()
4343
}
4444

4545
/**
46-
* @return int
46+
* @return int|bool
4747
*/
4848
protected function getLastRevisionTimestamp()
4949
{
5050
$table = 'data_' . $this->schema->getTable();
5151
$where = "WHERE pid = ?";
52-
$opts = array($this->pid);
52+
$opts = [$this->pid];
5353
if ($this->ts) {
54-
$where .= " AND rev <= ?";
54+
$where .= " AND REV > 0 AND rev <= ?";
5555
$opts[] = $this->ts;
5656
}
5757

5858
/** @noinspection SqlResolve */
5959
$sql = "SELECT rev FROM $table $where ORDER BY rev DESC LIMIT 1";
6060
$res = $this->sqlite->query($sql, $opts);
61-
$ret = (int) $this->sqlite->res2single($res);
61+
$ret = $this->sqlite->res2single($res);
6262
$this->sqlite->res_close($res);
63+
// make sure we don't cast empty result to 0 (serial data has rev = 0)
64+
if ($ret !== false) $ret = (int) $ret;
6365
return $ret;
6466
}
6567

0 commit comments

Comments
 (0)