Skip to content

Commit dde12e7

Browse files
authored
Merge pull request #554 from cosmocode/no-serial-in-page-editor
Never load serial data in page editor
2 parents d4a204b + 25e910d commit dde12e7

File tree

7 files changed

+43
-21
lines changed

7 files changed

+43
-21
lines changed

_test/AccessTableDataDB.test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ public function test_pseudodiff() {
299299
'multipage' => array('wiki:dokuwiki', 'wiki:syntax', 'wiki:welcome'),
300300
'singletitle' => 'wiki:dokuwiki',
301301
'multititle' => array('wiki:dokuwiki', 'wiki:syntax', 'wiki:welcome'),
302-
)
302+
),
303+
time()
303304
);
304305

305306
// make sure titles for some pages are known (not for wiki:welcome)

_test/AccessTableDataReplacement.test.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,33 @@ public function setUp() {
4242
$as->assignPageSchema('page2', 'bar');
4343
$as->assignPageSchema('page2', 'bar');
4444

45-
45+
// page data is saved with a rev timestamp
46+
$now = time();
4647
$this->saveData(
4748
'start',
4849
'foo',
4950
array(
5051
'pages' => array('page1', 'page2')
51-
)
52+
),
53+
$now
5254
);
5355

5456
$this->saveData(
5557
'page1',
5658
'bar',
5759
array(
5860
'data' => 'data of page1'
59-
)
61+
),
62+
$now
6063
);
6164

6265
$this->saveData(
6366
'page2',
6467
'bar',
6568
array(
6669
'data' => 'data of page2'
67-
)
70+
),
71+
$now
6872
);
6973
}
7074

_test/Search.test.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public function setUp() {
2626
$as->assignPageSchema($page, 'schema2');
2727
saveWikiText($page, "===== TestTitle =====\nabc", "Summary");
2828
p_get_metadata($page);
29+
$now = time();
2930
$this->saveData(
3031
$page,
3132
'schema1',
@@ -34,7 +35,8 @@ public function setUp() {
3435
'second' => array('second data', 'more data', 'even more'),
3536
'third' => 'third data',
3637
'fourth' => 'fourth data'
37-
)
38+
),
39+
$now
3840
);
3941
$this->saveData(
4042
$page,
@@ -44,7 +46,8 @@ public function setUp() {
4446
'asecond' => array('second data', 'more data', 'even more'),
4547
'athird' => 'third data',
4648
'afourth' => 'fourth data'
47-
)
49+
),
50+
$now
4851
);
4952

5053
$as->assignPageSchema('test:document', 'schema1');
@@ -57,7 +60,8 @@ public function setUp() {
5760
'second' => array('second', 'more'),
5861
'third' => '',
5962
'fourth' => 'fourth data'
60-
)
63+
),
64+
$now
6165
);
6266
$this->saveData(
6367
'test:document',
@@ -67,7 +71,8 @@ public function setUp() {
6771
'asecond' => array('second data', 'more data', 'even more'),
6872
'athird' => 'third data',
6973
'afourth' => 'fourth data'
70-
)
74+
),
75+
$now
7176
);
7277

7378
for($i = 10; $i <= 20; $i++) {
@@ -79,7 +84,8 @@ public function setUp() {
7984
'asecond' => array("page$i second data"),
8085
'athird' => "page$i third data",
8186
'afourth' => "page$i fourth data"
82-
)
87+
),
88+
$now
8389
);
8490
$as->assignPageSchema("page$i", 'schema2');
8591
}

_test/Type_Dropdown.test.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,30 @@ class Type_Dropdown_struct_test extends StructTest {
1515

1616
protected function preparePages() {
1717
$this->loadSchemaJSON('dropdowns');
18+
$now = time();
1819
$this->saveData(
1920
'test1',
2021
'dropdowns',
2122
[
2223
'drop1' => '["test1",1]', 'drop2' => '["test1",1]', 'drop3' => 'John'
23-
]
24+
],
25+
$now
2426
);
2527
$this->saveData(
2628
'test2',
2729
'dropdowns',
2830
[
2931
'drop1' => '["test1",2]', 'drop2' => '["test1",2]', 'drop3' => 'Jane'
30-
]
32+
],
33+
$now
3134
);
3235
$this->saveData(
3336
'test3',
3437
'dropdowns',
3538
[
3639
'drop1' => '["test1",3]', 'drop2' => '["test1",3]', 'drop3' => 'Tarzan'
37-
]
40+
],
41+
$now
3842
);
3943
}
4044

_test/edit.test.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ public function setUp() {
2626
'second' => array('second data', 'more data', 'even more'),
2727
'third' => 'third data',
2828
'fourth' => 'fourth data'
29-
)
29+
),
30+
time()
3031
);
3132
}
3233

_test/output.test.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function setUp() {
2424

2525
$page = 'page01';
2626
$includedPage = 'foo';
27+
$now = time();
2728
$this->saveData(
2829
$page,
2930
'schema1',
@@ -32,7 +33,8 @@ public function setUp() {
3233
'second' => array('second data', 'more data', 'even more'),
3334
'third' => 'third data',
3435
'fourth' => 'fourth data'
35-
)
36+
),
37+
$now
3638
);
3739
$this->saveData(
3840
$page,
@@ -42,7 +44,8 @@ public function setUp() {
4244
'second field' => array('second data', 'more data', 'even more'),
4345
'third%field' => 'third data',
4446
'fourth.field?' => 'fourth data'
45-
)
47+
),
48+
$now
4649
);
4750
$this->saveData(
4851
$includedPage,
@@ -52,7 +55,8 @@ public function setUp() {
5255
'second' => array('second data', 'more data', 'even more'),
5356
'third' => 'third data',
5457
'fourth' => 'fourth data'
55-
)
58+
),
59+
$now
5660
);
5761
}
5862

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)