Skip to content

Commit

Permalink
FileJournal: fixed 'Link is not in node' exception [Closes #12]
Browse files Browse the repository at this point in the history
That bug occur only in debug mode
  • Loading branch information
JakubOnderka authored and dg committed Dec 21, 2014
1 parent d071e06 commit 3076b11
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Caching/Storages/FileJournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,13 @@ private function cleanLinks(array $data, array & $toDelete)
do {
$link = $data[$i];

if (!isset($node[$link])) {
if (isset($this->deletedLinks[$link])) {
continue;
} elseif (!isset($node[$link])) {
if (self::$debug) {
throw new Nette\InvalidStateException("Link with ID $searchLink is not in node $nodeId.");
}
continue;
} elseif (isset($this->deletedLinks[$link])) {
continue;
}

$nodeLink = & $node[$link];
Expand Down
7 changes: 6 additions & 1 deletion tests/Caching/FileJournal.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function check($result, $condition, $name)
Assert::true($condition, $name . ($condition === TRUE ? '' : 'Count: ' . count($result)));
}


FileJournal::$debug = TRUE;
$journal = new FileJournal(TEMP_DIR);

$journal->write('ok_test1', array(
Expand Down Expand Up @@ -177,3 +177,8 @@ $journal->write('ok_test_all_priority', array(
$result = $journal->clean(array(Cache::ALL => TRUE));
$result2 = $journal->clean(array(Cache::TAGS => 'test:all'));
check($result, ($result === NULL and empty($result2)), 'Clean ALL');

$journal->write('a', array(Cache::TAGS => array('gamma')));
$journal->write('b', array(Cache::TAGS => array('alpha', 'beta', 'gamma')));
$result = $journal->clean(array(Cache::TAGS => array('alpha', 'beta', 'gamma')));
check($result, count($result) === 2, 'Remove item with multiple tags');

0 comments on commit 3076b11

Please sign in to comment.