1 | <?php |
||
8 | class CacheRenderer extends CacheParser |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * method contains cache use decision logic |
||
13 | * |
||
14 | * @return bool see useCache() |
||
15 | */ |
||
16 | public function makeDefaultCacheDecision() |
||
17 | { |
||
18 | global $conf; |
||
19 | |||
20 | if (!parent::makeDefaultCacheDecision()) { |
||
21 | return false; |
||
22 | } |
||
23 | |||
24 | if (!isset($this->page)) { |
||
25 | return true; |
||
26 | } |
||
27 | |||
28 | // meta cache older than file it depends on? |
||
29 | if ($this->_time < @filemtime(metaFN($this->page, '.meta'))) { |
||
30 | return false; |
||
31 | } |
||
32 | |||
33 | // check current link existence is consistent with cache version |
||
34 | // first check the purgefile |
||
35 | // - if the cache is more recent than the purgefile we know no links can have been updated |
||
36 | if ($this->_time >= @filemtime($conf['cachedir'] . '/purgefile')) { |
||
37 | return true; |
||
38 | } |
||
39 | |||
40 | // for wiki pages, check metadata dependencies |
||
41 | $metadata = p_get_metadata($this->page); |
||
42 | |||
43 | if (!isset($metadata['relation']['references']) || |
||
44 | empty($metadata['relation']['references'])) { |
||
45 | return true; |
||
46 | } |
||
47 | |||
48 | foreach ($metadata['relation']['references'] as $id => $exists) { |
||
49 | if ($exists != page_exists($id, '', false)) { |
||
50 | return false; |
||
51 | } |
||
52 | } |
||
53 | |||
54 | return true; |
||
55 | } |
||
56 | |||
57 | protected function addDependencies() |
||
94 | } |
||
95 |