Failed Conditions
Push — psr2 ( e24a74...d8b492 )
by Andreas
06:23 queued 03:20
created

inc/Cache/CacheParser.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace dokuwiki\Cache;
4
5
/**
6
 * Parser caching
7
 */
8
class CacheParser extends Cache
9
{
10
11
    public $file = '';       // source file for cache
12
    public $mode = '';       // input mode (represents the processing the input file will undergo)
13
    public $page = '';
14
15
    /**
16
     *
17
     * @param string $id page id
18
     * @param string $file source file for cache
19
     * @param string $mode input mode
20
     */
21
    public function __construct($id, $file, $mode)
22
    {
23
        if ($id) {
24
            $this->page = $id;
25
        }
26
        $this->file = $file;
27
        $this->mode = $mode;
28
29
        $this->_event = 'PARSER_CACHE_USE';
0 ignored issues
show
Deprecated Code introduced by
The property dokuwiki\Cache\Cache::$_event has been deprecated with message: since 2019-02-02 use the respective getters instead!

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
30
        parent::__construct($file . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'], '.' . $mode);
31
    }
32
33
    /**
34
     * method contains cache use decision logic
35
     *
36
     * @return bool               see useCache()
37
     */
38
    public function makeDefaultCacheDecision()
39
    {
40
41
        if (!file_exists($this->file)) {
42
            return false;
43
        }                   // source exists?
44
        return parent::makeDefaultCacheDecision();
45
    }
46
47
    protected function addDependencies()
48
    {
49
50
        // parser cache file dependencies ...
51
        $files = array(
52
            $this->file,                              // ... source
53
            DOKU_INC . 'inc/parser/Parser.php',                // ... parser
54
            DOKU_INC . 'inc/parser/handler.php',               // ... handler
55
        );
56
        $files = array_merge($files, getConfigFiles('main'));    // ... wiki settings
57
58
        $this->depends['files'] = !empty($this->depends['files']) ?
59
            array_merge($files, $this->depends['files']) :
60
            $files;
61
        parent::addDependencies();
62
    }
63
64
}
65