1 | <?php |
||
30 | class CacheManager |
||
31 | { |
||
32 | /** |
||
33 | * Cache Access objects for pools |
||
34 | * |
||
35 | * @var Access[] |
||
36 | */ |
||
37 | protected $pools = []; |
||
38 | |||
39 | /** |
||
40 | * Pool definitions |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $poolDefs = []; |
||
45 | |||
46 | /** |
||
47 | * Xoops instance |
||
48 | * |
||
49 | * @var \Xoops |
||
50 | */ |
||
51 | protected $xoops; |
||
52 | |||
53 | /** |
||
54 | * __construct |
||
55 | */ |
||
56 | 1 | public function __construct() |
|
57 | { |
||
58 | 1 | $this->xoops = \Xoops::getInstance(); |
|
59 | 1 | $defaults = $this->getDefaults(); |
|
60 | 1 | $xoops_var_path = \XoopsBaseConfig::get('var-path'); |
|
61 | 1 | $cache_file = $xoops_var_path . '/configs/cache.php'; |
|
62 | 1 | $poolDefs = Yaml::readWrapped($cache_file); |
|
63 | 1 | if (empty($poolDefs)) { |
|
64 | Yaml::saveWrapped($defaults, $cache_file); |
||
65 | } |
||
66 | 1 | $poolDefs = is_array($poolDefs) ? $poolDefs : array(); |
|
67 | 1 | $this->poolDefs = array_merge($defaults, $poolDefs); |
|
68 | 1 | } |
|
69 | |||
70 | /** |
||
71 | * getDefaults get default cache configuration used if there is no config file |
||
72 | * |
||
73 | * @return array cache configuration |
||
74 | */ |
||
75 | 1 | private static function getDefaults() |
|
76 | { |
||
77 | |||
78 | $defaults = [ |
||
79 | 1 | 'default' => [ |
|
80 | 1 | 'driver' => 'Sqlite', |
|
81 | 1 | 'options' => ['path' => \XoopsBaseConfig::get('var-path') . '/stash/'], |
|
82 | ], |
||
83 | 'temp' => [ |
||
84 | 'driver' => 'Ephemeral', |
||
85 | 'options' => [], |
||
86 | ], |
||
87 | ]; |
||
88 | 1 | return $defaults; |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * Create a default configuration file, used in installation |
||
93 | * |
||
94 | * SQLite is the recommended driver, and will be used by default if available. |
||
95 | * |
||
96 | * We will fall back to FileSystem if SQLite is not available. |
||
97 | * |
||
98 | * Note: some versions of the Stash FileSystem driver appear susceptible to |
||
99 | * race conditions which may cause random failures. |
||
100 | * |
||
101 | * Note for Windows users: |
||
102 | * |
||
103 | * When using Windows NTFS, PHP has a maximum path length of 260 bytes. Each key level in a |
||
104 | * Stash hierarchical key corresponds to a directory, and is normalized as an md5 hash. Also, |
||
105 | * Stash uses 2 levels for its own integrity and locking mechanisms. The full key length used |
||
106 | * in XoopCore can reach 202 characters. |
||
107 | * |
||
108 | * Installing the pdo_sqlite3 extension is highly recommended to avoid problems. |
||
109 | * |
||
110 | * @return void |
||
111 | */ |
||
112 | public static function createDefaultConfig() |
||
131 | |||
132 | /** |
||
133 | * Get a cache corresponding to the specified name |
||
134 | * |
||
135 | * @param string $name Name of cache definition |
||
136 | * |
||
137 | * @return Access object |
||
138 | */ |
||
139 | 39 | public function getCache($name) |
|
155 | |||
156 | /** |
||
157 | * Instantiate an Access object from named configuration, including |
||
158 | * instantiating pool and driver |
||
159 | * |
||
160 | * @param string $name name of pool configuration to start |
||
161 | * |
||
162 | * @return Access|false pool or false if a pool cannot be created |
||
163 | */ |
||
164 | 1 | protected function startPoolAccess($name) |
|
195 | |||
196 | /** |
||
197 | * getDriver |
||
198 | * |
||
199 | * @param string $driverName short name of the driver |
||
200 | * @param array $options array of options for the driver |
||
201 | * |
||
202 | * @return DriverInterface|false driver object or false if it could not be instantiated |
||
203 | */ |
||
204 | 1 | protected function getDriver($driverName, $options) |
|
215 | |||
216 | /** |
||
217 | * Get an Access object based on the default pool. If it isn't set, create it. |
||
218 | * If no definition exists for default, use Stash default (Ephimeral.) |
||
219 | * |
||
220 | * @param string $originalName originally requested pool configuration name |
||
221 | * |
||
222 | * @return Access object |
||
223 | */ |
||
224 | 1 | protected function getDefaultPool($originalName) |
|
239 | } |
||
240 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.