Skip to content

Commit 3076b11

Browse files
JakubOnderkadg
authored andcommitted
FileJournal: fixed 'Link is not in node' exception [Closes #12]
That bug occur only in debug mode
1 parent d071e06 commit 3076b11

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Caching/Storages/FileJournal.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,13 @@ private function cleanLinks(array $data, array & $toDelete)
381381
do {
382382
$link = $data[$i];
383383

384-
if (!isset($node[$link])) {
384+
if (isset($this->deletedLinks[$link])) {
385+
continue;
386+
} elseif (!isset($node[$link])) {
385387
if (self::$debug) {
386388
throw new Nette\InvalidStateException("Link with ID $searchLink is not in node $nodeId.");
387389
}
388390
continue;
389-
} elseif (isset($this->deletedLinks[$link])) {
390-
continue;
391391
}
392392

393393
$nodeLink = & $node[$link];

tests/Caching/FileJournal.phpt

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function check($result, $condition, $name)
1717
Assert::true($condition, $name . ($condition === TRUE ? '' : 'Count: ' . count($result)));
1818
}
1919

20-
20+
FileJournal::$debug = TRUE;
2121
$journal = new FileJournal(TEMP_DIR);
2222

2323
$journal->write('ok_test1', array(
@@ -177,3 +177,8 @@ $journal->write('ok_test_all_priority', array(
177177
$result = $journal->clean(array(Cache::ALL => TRUE));
178178
$result2 = $journal->clean(array(Cache::TAGS => 'test:all'));
179179
check($result, ($result === NULL and empty($result2)), 'Clean ALL');
180+
181+
$journal->write('a', array(Cache::TAGS => array('gamma')));
182+
$journal->write('b', array(Cache::TAGS => array('alpha', 'beta', 'gamma')));
183+
$result = $journal->clean(array(Cache::TAGS => array('alpha', 'beta', 'gamma')));
184+
check($result, count($result) === 2, 'Remove item with multiple tags');

0 commit comments

Comments
 (0)